Validation 15/03/22 - 10h21

master
ChérifBALDE 2022-03-15 18:46:50 +01:00 committed by cherif
parent 783f460562
commit d20ea532e9
6 changed files with 57 additions and 51 deletions

View File

@ -131,7 +131,7 @@ def add_class(diction):
if ("price" in diction.keys()):
if diction['price']:
mydata['price'] = diction['price']
mydata['price'] = int(str(diction['price']))
if ("url" in diction.keys()):
if diction['url']:
@ -298,7 +298,7 @@ def update_class(diction):
if ("price" in diction.keys()):
if diction['price']:
mydata['price'] = diction['price']
mydata['price'] = int(str(diction['price']))
if ("url" in diction.keys()):
if diction['url']:

View File

@ -1,2 +1,3 @@
,index,mots,occurence,moyenne,id_formation,source_field
0,0,mot1,1,1.0,code01,keyword
0,0,ger,1,0.5,MAN10,title
1,1,polyvalent,1,0.5,MAN10,title

1 index mots occurence moyenne id_formation source_field
2 0 0 mot1 ger 1 1.0 0.5 code01 MAN10 keyword title
3 1 1 polyvalent 1 0.5 MAN10 title

View File

@ -158,7 +158,8 @@ def ela_index_class(external_code="", source_field = ""):
return True
except Exception as e:
mycommon.myprint(e)
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False
@ -192,24 +193,26 @@ def ela_index_all_classes():
nb_class_indexed = 0
for doc in collection.find({'indexed':'0'}):
chaine = doc["title"]+" - "+doc["description"]
mycommon.myprint(" external_code = "+str(doc["external_code"])+" ==> "+str(chaine))
retval = ela_index_class(str(doc["external_code"]))
print(" apres : ela_index_class retval = "+str(retval))
if ("title" in doc.keys() and "description" in doc.keys() ):
chaine = doc["title"]+" - "+doc["description"]
mycommon.myprint(" external_code = "+str(doc["external_code"])+" ==> "+str(chaine))
retval = ela_index_class(str(doc["external_code"]))
print(" apres : ela_index_class retval = "+str(retval))
if( retval is False):
mycommon.myprint("IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed+1
if( retval is False):
mycommon.myprint("IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed+1
#retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
#retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
mycommon.myprint(str(nb_class_indexed)+" ont été indexes")
return True, str(nb_class_indexed)+" ont été indexes "
except Exception as e:
mycommon.myprint(e)
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, "Impossible d'indexer la BDD des formations ==> KO"
'''
@ -275,17 +278,18 @@ def ela_index_all_classes_title():
nb_class_indexed = 0
for doc in collection.find({'indexed_title': '0'}):
chaine = doc["title"]
mycommon.myprint(" external_code = " + str(doc["external_code"]) + " ==> " + str(chaine))
retval = ela_index_class(str(doc["external_code"]), "title")
print(" apres : ela_index_all_classes_title retval = " + str(retval))
if ("title" in doc.keys()):
chaine = doc["title"]
mycommon.myprint(" external_code = " + str(doc["external_code"]) + " ==> " + str(chaine))
retval = ela_index_class(str(doc["external_code"]), "title")
print(" apres : ela_index_all_classes_title retval = " + str(retval))
if (retval is False):
mycommon.myprint(str(inspect.stack()[0][3]) + "IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed + 1
if (retval is False):
mycommon.myprint(str(inspect.stack()[0][3]) + "IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed + 1
# retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
# retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
mycommon.myprint(str(nb_class_indexed) + " ont été indexes")
return True, str(nb_class_indexed) + " ont été indexes "
@ -329,23 +333,25 @@ def ela_index_all_classes_desc():
nb_class_indexed = 0
for doc in collection.find({'indexed_desc': '0'}):
chaine = doc["description"]
mycommon.myprint(" external_code = " + str(doc["external_code"]) + " ==> " + str(chaine))
retval = ela_index_class(str(doc["external_code"]), "description")
print(" apres : ela_index_all_classes_title retval = " + str(retval))
if ("description" in doc.keys()):
chaine = doc["description"]
mycommon.myprint(" external_code = " + str(doc["external_code"]) + " ==> " + str(chaine))
retval = ela_index_class(str(doc["external_code"]), "description")
print(" apres : ela_index_all_classes_title retval = " + str(retval))
if (retval is False):
mycommon.myprint("IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed + 1
if (retval is False):
mycommon.myprint("IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed + 1
# retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
# retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
mycommon.myprint(str(nb_class_indexed) + " ont été indexes - champ description")
return True, str(nb_class_indexed) + " ont été indexes - champ description "
except Exception as e:
mycommon.myprint(e)
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, "Impossible d'indexer la BDD des formations ==> KO"
@ -379,23 +385,25 @@ def ela_index_all_classes_obj():
nb_class_indexed = 0
for doc in collection.find({'indexed_obj': '0'}):
chaine = doc["objectif"]
mycommon.myprint(" external_code = " + str(doc["external_code"]) + " ==> " + str(chaine))
retval = ela_index_class(str(doc["external_code"]), "objectif")
print(" apres : ela_index_all_classes_title retval = " + str(retval))
if ("objectif" in doc.keys()):
chaine = doc["objectif"]
mycommon.myprint(" external_code = " + str(doc["external_code"]) + " ==> " + str(chaine))
retval = ela_index_class(str(doc["external_code"]), "objectif")
print(" apres : ela_index_all_classes_title retval = " + str(retval))
if (retval is False):
mycommon.myprint("IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed + 1
if (retval is False):
mycommon.myprint("IMPOSSIBLE d'indexer la formation = " + str(doc["external_code"]))
else:
nb_class_indexed = nb_class_indexed + 1
# retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
# retval = ls.ela_index_record_field(chaine, str(doc["external_code"]))
mycommon.myprint(str(nb_class_indexed) + " ont été indexes - champ objectif")
return True, str(nb_class_indexed) + " ont été indexes - champ objectif "
except Exception as e:
mycommon.myprint(e)
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, "Impossible d'indexer la BDD des formations ==> KO"

View File

@ -1,2 +1,3 @@
mots occurence moyenne id_formation source_field
0 mot1 1 1.0 code01 keyword
mots occurence moyenne id_formation source_field
0 ger 1 0.5 MAN10 title
1 polyvalent 1 0.5 MAN10 title

View File

@ -55,7 +55,7 @@ def add_partner_account(diction):
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['nom', 'adr_street', 'adr_city', 'adr_zip', 'adr_country','link_linkedin','link_facebook','link_twitter'
field_list = ['nom', 'adr_street', 'adr_city', 'adr_zip', 'adr_country','link_linkedin','link_facebook','link_twitter',
'email','pwd', 'telephone','contact_nom','contact_prenom','contact_tel','contact_mail']
incom_keys = diction.keys()
for val in incom_keys:

View File

@ -257,7 +257,6 @@ def recherche_text_simple(diction):
json = {}
if ("price" in diction.keys()):
if diction['price']:
critere_date['price'] = diction['price']
if( str( diction['price']) != "NA"):
prices = str(diction['price']).split(":")
if len(prices) > 2 :
@ -267,9 +266,6 @@ def recherche_text_simple(diction):
price_crit = {'price': {'$gte': int(str(prices[0])), '$lte': int(str(prices[1]))}}
new_diction['price'] = diction['price']
print("{#############"+str(price_crit))
support_crit = {}
if ("support" in diction.keys()):
@ -339,7 +335,7 @@ def recherche_text_simple(diction):
'''
Verification si le texte de recherche contient un pattern de tips,
c'est a dire une chaine de type : title:titre
c'est a dire une chaine de type : title:"titre"
Si c'est le cas, nous sommes dans le cadre d'un recherche par type