31/03/22 - 22h35
parent
e7122b862f
commit
15b5aa2c60
62
wrapper.py
62
wrapper.py
|
@ -55,6 +55,9 @@ def get_recherche_gle_class(sentence):
|
||||||
coll_name = dbname['myclass']
|
coll_name = dbname['myclass']
|
||||||
|
|
||||||
insertObject = []
|
insertObject = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for x in coll_name.find({"external_code": {"$in": tab_training}}, {"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0, "valide": 0,
|
for x in coll_name.find({"external_code": {"$in": tab_training}}, {"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0, "valide": 0,
|
||||||
"locked": 0, "partner_owner_recid": 0, }):
|
"locked": 0, "partner_owner_recid": 0, }):
|
||||||
mycommon.myprint(x)
|
mycommon.myprint(x)
|
||||||
|
@ -506,39 +509,42 @@ def recherche_text_simple(diction):
|
||||||
si ce n'est pas le cas, il faudra à la fin enregistrer la requete avec un result a vide'''
|
si ce n'est pas le cas, il faudra à la fin enregistrer la requete avec un result a vide'''
|
||||||
nb_result = 0
|
nb_result = 0
|
||||||
insertObject = []
|
insertObject = []
|
||||||
for x in coll_name.find(({"$and": [{"external_code": {"$in": tab_training}},
|
|
||||||
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, }):
|
|
||||||
nb_result = nb_result + 1
|
|
||||||
my_recid = {}
|
|
||||||
my_recid['user_rec_id'] = str(user_recid)
|
|
||||||
mydict_combined = {**diction, **x, **my_recid}
|
|
||||||
mydict_combined['date_update'] = str(datetime.now())
|
|
||||||
mydict_combined['type_view'] = "summary"
|
|
||||||
|
|
||||||
if ("_id" in mydict_combined.keys()):
|
for val in tab_training:
|
||||||
mydict_combined['class_id'] = mydict_combined.pop('_id')
|
|
||||||
|
|
||||||
#mycommon.myprint("COMBINED = " + str(mydict_combined))
|
for x in coll_name.find(({"$and": [ {"external_code": str(val) },
|
||||||
|
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, }):
|
||||||
|
nb_result = nb_result + 1
|
||||||
|
my_recid = {}
|
||||||
|
my_recid['user_rec_id'] = str(user_recid)
|
||||||
|
mydict_combined = {**diction, **x, **my_recid}
|
||||||
|
mydict_combined['date_update'] = str(datetime.now())
|
||||||
|
mydict_combined['type_view'] = "summary"
|
||||||
|
|
||||||
'''
|
if ("_id" in mydict_combined.keys()):
|
||||||
Statistique : Insertion du recherche - resultat '''
|
mydict_combined['class_id'] = mydict_combined.pop('_id')
|
||||||
ret_val_tmp = coll_search_result.insert_one(mydict_combined)
|
|
||||||
if (ret_val_tmp is False):
|
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour la table des resultat"
|
|
||||||
" d'une recherche de formation. Voir _id = ")
|
|
||||||
return False, "La recheche est impossible "
|
|
||||||
|
|
||||||
user = x
|
#mycommon.myprint("COMBINED = " + str(mydict_combined))
|
||||||
val = x['description']
|
|
||||||
if (len(x['description']) > MAX_CARACT):
|
|
||||||
x['description'] = val[:MAX_CARACT] + " ..."
|
|
||||||
else:
|
|
||||||
x['description'] = val[:MAX_CARACT]
|
|
||||||
insertObject.append(JSONEncoder().encode(user))
|
|
||||||
|
|
||||||
# mycommon.myprint(" insertObject = ", insertObject)
|
'''
|
||||||
|
Statistique : Insertion du recherche - resultat '''
|
||||||
|
ret_val_tmp = coll_search_result.insert_one(mydict_combined)
|
||||||
|
if (ret_val_tmp is False):
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour la table des resultat"
|
||||||
|
" d'une recherche de formation. Voir _id = ")
|
||||||
|
return False, "La recheche est impossible "
|
||||||
|
|
||||||
|
user = x
|
||||||
|
val = x['description']
|
||||||
|
if (len(x['description']) > MAX_CARACT):
|
||||||
|
x['description'] = val[:MAX_CARACT] + " ..."
|
||||||
|
else:
|
||||||
|
x['description'] = val[:MAX_CARACT]
|
||||||
|
insertObject.append(JSONEncoder().encode(user))
|
||||||
|
|
||||||
|
#print(insertObject)
|
||||||
|
|
||||||
''' en cas de resultat vide, enregsitrement de la requete de recherche avec les filtres associé'''
|
''' en cas de resultat vide, enregsitrement de la requete de recherche avec les filtres associé'''
|
||||||
if (nb_result == 0):
|
if (nb_result == 0):
|
||||||
|
|
Loading…
Reference in New Issue