From a0623166a2084a95c413119ea4ded35e3926d59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ch=C3=A9rifBALDE?= Date: Sat, 1 Oct 2022 00:21:00 +0200 Subject: [PATCH] 30/09/22 - 23h00 --- GlobalVariable.py | 2 +- data_indexees.csv | 6 +++--- ela_output_test_file_pandas_2.txt | 8 ++++---- statistics.py | 24 +++++++++++------------- wrapper.py | 19 ++++++++++++++++++- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/GlobalVariable.py b/GlobalVariable.py index 8cf2d20..f9ff744 100644 --- a/GlobalVariable.py +++ b/GlobalVariable.py @@ -117,7 +117,7 @@ QUERY_LIMIT_ROW = 50 ''' Cette variable definit le nombre max retour à faire sur page d'acceuil ''' -MAINPAGE_QUERY_LIMIT_ROW = 55 +MAINPAGE_QUERY_LIMIT_ROW = 4 ''' diff --git a/data_indexees.csv b/data_indexees.csv index 0cba612..21dbefb 100644 --- a/data_indexees.csv +++ b/data_indexees.csv @@ -1,4 +1,4 @@ ,index,mots,occurence,moyenne,id_formation,source_field -0,0,comprendre,1,0.33,CH_PA1201910,title -1,1,develov,1,0.33,CH_PA1201910,title -2,2,cherif,1,0.33,CH_PA1201910,title +0,0,after,1,0.33,VP14120,title +1,1,effect,1,0.33,VP14120,title +2,2,essentiel,1,0.33,VP14120,title diff --git a/ela_output_test_file_pandas_2.txt b/ela_output_test_file_pandas_2.txt index 95e810b..949d725 100644 --- a/ela_output_test_file_pandas_2.txt +++ b/ela_output_test_file_pandas_2.txt @@ -1,4 +1,4 @@ - mots occurence moyenne id_formation source_field -0 comprendre 1 0.33 CH_PA1201910 title -1 develov 1 0.33 CH_PA1201910 title -2 cherif 1 0.33 CH_PA1201910 title \ No newline at end of file + mots occurence moyenne id_formation source_field +0 after 1 0.33 VP14120 title +1 effect 1 0.33 VP14120 title +2 essentiel 1 0.33 VP14120 title \ No newline at end of file diff --git a/statistics.py b/statistics.py index 16c56a7..3b483ec 100644 --- a/statistics.py +++ b/statistics.py @@ -203,25 +203,24 @@ def GetStat_class_view(diction): pipe2 = [ {'$match': {'date_update' : { '$gte' : str(date_start), '$lte' : str(date_end)}, - 'partner_owner_recid':str(user_recid) + 'partner_owner_recid':str(user_recid), }}, { '$group': { '_id': { - - "OWNER": "$owner", "Date_view": {"$substr": ["$date_update", 0, SUBSTR]}, + "OWNER": "$partner_owner_recid", }, 'count': {'$count': {} } } }, { - "$sort": {"count": -1} + "$sort": {"_id": 1} } ] - #print(" PIP 2 ="+str(pipe2)) + print(" PIP 21 ="+str(pipe2)) insertObject = [] for result in collection.aggregate(pipe2): @@ -326,7 +325,6 @@ def GetStat_class_view_topX(diction): local_status, try_end_date = mycommon.TryToDateYYYMMDD(str(diction['date_end'])) new_end_date = try_end_date.date() - local_status, try_from_date = mycommon.TryToDateYYYMMDD(str(diction['date_start'])) new_from_date = try_from_date.date() @@ -335,10 +333,10 @@ def GetStat_class_view_topX(diction): categories = {} categories_val = "" - while ( tmp > -10 and str(day_before) != str(new_from_date) ) : - tmp = tmp - 1 - day_before = new_end_date + timedelta(days=tmp) - categories_val = categories_val+str(day_before)+"," + while ( tmp < 10 and str(day_before) != str(new_from_date) ) : + day_after = new_from_date + timedelta(days=tmp) + categories_val = categories_val+str(day_after)+"," + tmp = tmp + 1 #print(" day_before DATE = " + str(day_before)+ " VS "+str(new_from_date)) if(categories_val.endswith(',') ): @@ -421,8 +419,8 @@ def GetStat_class_view_topX(diction): '$group': { '_id': { "Date_view": {"$substr": ["$date_update", 0, SUBSTR]}, - "INTERNAL URL": "$internal_url", "OWNER": "$owner", + "INTERNAL URL": "$internal_url", }, 'count': {'$count': {} @@ -435,7 +433,7 @@ def GetStat_class_view_topX(diction): ] - print(" PIP 2 ="+str(pipe2)) + print(" PIP 22 ="+str(pipe2)) for result in collection.aggregate(pipe2): print(str(result['_id']) + " ===> " + str(result['count'])) @@ -764,7 +762,7 @@ def GetStat_class_by_internal_url(diction): ] - #print(" PIP 2 ="+str(pipe2)) + #print(" PIP 23 ="+str(pipe2)) #for result in collection.aggregate(pipe2): # print(str(result['_id']) + " ===> " + str(result['count'])) diff --git a/wrapper.py b/wrapper.py index 7dbb397..6879566 100644 --- a/wrapper.py +++ b/wrapper.py @@ -183,7 +183,21 @@ def get_all_class(diction): nb_formation_a_jouter = MYSY_GV.MAINPAGE_QUERY_LIMIT_ROW - len(tab_training_inzone) + #print(" #### get_all_class : nb_formation_a_jouter "+str(nb_formation_a_jouter)+" " + # "MYSY_GV.MAINPAGE_QUERY_LIMIT_ROW = "+str(MYSY_GV.MAINPAGE_QUERY_LIMIT_ROW)+" len(tab_training_inzone) = "+ + # str(len(tab_training_inzone) )) + + """ + Travail à faire : + le bug actuel vient du fait que la 2ieme requete ci-dessous qui complete la liste des formation + ajoute les formations deja trouvée dans la requete d'en haute. + + A faire : faire en sorte que la requete d'en dessous exclus les elements deja trouvée dans lreque en dessus. + + + """ + sdsqqs coll_name = MYSY_GV.dbname['myclass'] val_tmp = len(tab_training_inzone) @@ -305,7 +319,9 @@ def get_training_in_user_zone(diction): coll_name = MYSY_GV.dbname['myclass'] val_tmp = 1 insertObject = [] - print(" critère de recherche : user_country_code = "+str(mydata['user_country_code']).lower()+" ---- user_city = "+str(mydata['user_city']).lower()) + + + print(" ########## critère de recherche : user_country_code = "+str(mydata['user_country_code']).lower()+" ---- user_city = "+str(mydata['user_city']).lower()) for x in coll_name.find({ "$or": [ {'valide':'1', 'locked':'0', 'isalaune':'1','published':'1', "zone_diffusion.country":str(mydata['user_country_code']).lower()}, {'valide':'1', 'locked':'0', 'isalaune':'1', 'published':'1', "zone_diffusion.city":str(mydata['user_city']).lower()} ] }, {"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0, @@ -328,6 +344,7 @@ def get_training_in_user_zone(diction): user = x user['id'] = str(val_tmp) + print(" dans:get_training_in_user_zone return user = "+str(user['title'])) insertObject.append(JSONEncoder().encode(user)) val_tmp = val_tmp + 1