Validation 18/03/22 - 12h21

master
ChérifBALDE 2022-03-19 13:24:54 +01:00 committed by cherif
parent c70ef33e42
commit 102bc13cee
4 changed files with 4887 additions and 17 deletions

File diff suppressed because it is too large Load Diff

View File

@ -139,7 +139,7 @@ def add_class(diction):
if ("duree_formation" in diction.keys()):
if diction['duree_formation']:
mydata['duree_formation'] = int(str(diction['duree_formation']))
mydata['duree_formation'] = float(str(diction['duree_formation']))
@ -306,7 +306,7 @@ def update_class(diction):
if ("duree_formation" in diction.keys()):
if diction['duree_formation']:
mydata['duree_formation'] = diction['duree_formation']
mydata['duree_formation'] = float(str(diction['duree_formation']))
if ("plus_produit" in diction.keys()):
@ -1169,7 +1169,7 @@ def add_class_mass(file=None, Folder=None, diction=None):
mydata['institut_formation'] = str(df['institut_formation'].values[n])
mydata['distantiel'] = str(df['presentiel'].values[n])
mydata['url'] = str(df['url'].values[n])
mydata['duree_formation'] = int(str(df['duree_formation'].values[n]))
mydata['duree_formation'] = float(str(df['duree_formation'].values[n]))
mydata['plus_produit'] = str(df['plus_produit'].values[n])
mydata['mots_cle'] = str(df['mots_cle'].values[n])
'''

View File

@ -218,4 +218,31 @@ def levenshtein(mot1,mot2):
# Lorsque l'on sort de la boucle, i vaut len(mot2)
#Ce que l'on cherche est la distance de levenshtein entre les len(mot1) premières lettres de mot1
# et les len(mot2) premières lettres de mot2, qui est stockée dans ligne_i[len(mot1)]
return ligne_i[len(mot1)]
return ligne_i[len(mot1)]
'''
Check if string is float and convert.
0 if error
'''
def tryFloat(val):
try:
val = str(val).replace(",",".")
myfloat = float(val)
return myfloat
except ValueError:
return 0
'''
Check if string is Int and convert.
0 if error
'''
def tryInt(val):
try:
val = str(val).replace(",",".")
tab_val = val.split(".")
myfloat = int(tab_val[0])
return myfloat
except ValueError:
return 0

View File

@ -277,8 +277,7 @@ def recherche_text_simple(diction):
if len(prices) > 2 :
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le filtre 'price' a plus 2 informations")
return False, " Le filtre prix est incorrect"
price_crit = {'price': {'$gte': int(str(prices[0])), '$lte': int(str(prices[1]))}}
price_crit = {'price': {'$gte': mycommon.tryInt(str(prices[0])), '$lte': mycommon.tryInt(str(prices[1]))}}
@ -308,6 +307,7 @@ def recherche_text_simple(diction):
lang_crit['lang'] = diction['lang']
new_diction['lang'] = diction['lang']
distance_crit = {}
if ("distance" in diction.keys()):
if diction['distance']:
@ -322,7 +322,9 @@ def recherche_text_simple(diction):
if diction['duration']:
if (str(diction['duration']) != "0"):
duration_crit['duration'] = diction['duration']
new_diction['duration'] = diction['duration']
new_diction['duration'] = mycommon.tryFloat(diction['duration'])
duration_crit = {
'duree_formation': {'$lte': mycommon.tryInt( str(diction['duration']) )}}
'''
/!\ Important : si le token est vide, alors c'est une recherche faite en mode non-connecté.
@ -349,7 +351,7 @@ def recherche_text_simple(diction):
return False, " Impossible de desactiver l'objectif utilisateur"
mycommon.myprint(" On recehrche la phrase +'" + search_text + "'")
mycommon.myprint(" On recehrche la phrase +'" + search_text + "' + user_recid = "+user_recid)
# Enregistrerment de la recherche
retval, message, store_recherche_Id = store_recherche(diction, user_recid)
@ -389,19 +391,20 @@ def recherche_text_simple(diction):
final_message.append(message)
print(" liste defitive des ref "+str(final_message))
#print(" liste defitive des ref "+str(final_message))
final_message2 = []
for t in final_message:
if( t is not False):
for y in t:
print( " unique = "+str(y))
#print( " unique = "+str(y))
final_message2.append(y)
coll_name = dbname['myclass']
print(" Dans la recherch TIPS , les critère = " + str(certif_crit) + " la langue = " + str(
lang_crit) + " price = " + str(price_crit)+" support = "+str(support_crit), " price_crit = "+str(price_crit))
lang_crit) + " price = " + str(price_crit)+" support = "+str(support_crit),
" price_crit = "+str(price_crit), "duration_crit = "+str(duration_crit))
'''
A present mise à jour de la table "user_recherche" avec les resultats trouvés
@ -430,7 +433,8 @@ def recherche_text_simple(diction):
si ce n'est pas le cas, il faudra à la fin enregistrer la requete avec un result a vide'''
nb_result = 0
for x in coll_name.find(({"$and": [{"external_code": {"$in": final_message2}},
certif_crit, lang_crit, type_crit, price_crit, support_crit]}),
certif_crit, lang_crit, type_crit, price_crit,
support_crit, duration_crit]}),
{"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0,
"indexed_title": 0, "valide": 0, "locked": 0, "partner_owner_recid": 0, }):
@ -758,12 +762,12 @@ def recherche_tips_ret_ref(diction):
#print(" RRRRR "+str(diction))
field_list = ['search_text', 'token', 'support', 'id',
'type', 'lang', 'level', 'dist', 'price',
'certif', 'source', 'name','valide']
'certif', 'source', 'name','valide', 'duration', 'distance']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
mycommon.myprint(str(inspect.stack()[0][3])+" - Le champ '" + val + "' n'existe pas, recherche annulée")
return False, " Le champ '" + val + "' n'existe pas, recherche annulée"
mycommon.myprint(str(inspect.stack()[0][3])+" - Le champ '" + val + "' n'est pas autorisé, recherche annulée")
return False, " Le champ '" + val + "' n'est pas autorisé, recherche annulée"
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
@ -786,7 +790,7 @@ def recherche_tips_ret_ref(diction):
return False, "Impossible d'enregistrer la recherche"
print(" ####### recherche tips, voici mon new diction"+str(diction))
print(" ####### recherche tips, voici mon new diction"+str(diction)+ " user_recid = "+user_recid)
# Enregistrerment de la recherche
retval, message, store_recherche_Id = store_recherche(diction, user_recid)
@ -919,7 +923,7 @@ def recherche_tips(diction):
return False, "Impossible d'enregistrer la recherche"
print(" ####### recherche tips, voici mon new diction"+str(diction))
print(" ####### recherche tips, voici mon new diction"+str(diction)+" RRRC ID = "+user_recid)
# Enregistrerment de la recherche
retval, message, store_recherche_Id = store_recherche(diction, user_recid)