diff --git a/class_mgt.py b/class_mgt.py index c00c39f..5532471 100644 --- a/class_mgt.py +++ b/class_mgt.py @@ -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']: diff --git a/data_indexees.csv b/data_indexees.csv index d146f3c..150a06f 100644 --- a/data_indexees.csv +++ b/data_indexees.csv @@ -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 diff --git a/ela_index_bdd_classes.py b/ela_index_bdd_classes.py index e387cc5..45c4554 100644 --- a/ela_index_bdd_classes.py +++ b/ela_index_bdd_classes.py @@ -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" diff --git a/ela_output_test_file_pandas_2.txt b/ela_output_test_file_pandas_2.txt index 16b4647..93566dd 100644 --- a/ela_output_test_file_pandas_2.txt +++ b/ela_output_test_file_pandas_2.txt @@ -1,2 +1,3 @@ - mots occurence moyenne id_formation source_field -0 mot1 1 1.0 code01 keyword \ No newline at end of file + mots occurence moyenne id_formation source_field +0 ger 1 0.5 MAN10 title +1 polyvalent 1 0.5 MAN10 title \ No newline at end of file diff --git a/partners.py b/partners.py index 418826f..f1b599e 100644 --- a/partners.py +++ b/partners.py @@ -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: diff --git a/wrapper.py b/wrapper.py index dadc9d9..37cc018 100644 --- a/wrapper.py +++ b/wrapper.py @@ -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