14/09/22 - 16h30
parent
bd43101206
commit
98847be9d5
520005
Log/log_file.log
520005
Log/log_file.log
File diff suppressed because one or more lines are too long
24
main.py
24
main.py
|
@ -1426,6 +1426,30 @@ def Get_X_Best_Class_On_Given_period():
|
|||
return jsonify(status=status, message=message)
|
||||
|
||||
|
||||
@app.route('/myclass/api/test_return/', methods=['GET','POST'])
|
||||
@crossdomain(origin='*')
|
||||
def test_return():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### payload = ", str(payload))
|
||||
status, message = Stat.test_return()
|
||||
return jsonify(status=status, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API de suppression du compte de LS"""
|
||||
@app.route('/myclass/api/removeLSaccount/', methods=['GET','POST'])
|
||||
@crossdomain(origin='*')
|
||||
def removeLSaccount():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### payload = ", str(payload))
|
||||
status, message = mycommon.removeLSaccount()
|
||||
return jsonify(status=status, message=message)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||
|
|
|
@ -1742,3 +1742,20 @@ def InsertStatistic(diction_class, type_view, user_location):
|
|||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
|
||||
|
||||
"""
|
||||
Suppression du compte de LS
|
||||
"""
|
||||
def removeLSaccount():
|
||||
try:
|
||||
coll = MYSY_GV.dbname["partnair_account"]
|
||||
myquery = {"email": "ls.lutmanmicca@gmail.com"}
|
||||
x = coll.delete_many(myquery)
|
||||
print(x.deleted_count, " documents deleted.")
|
||||
return True, str(x.deleted_count) + " documents deleted."
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
|
|
110
statistics.py
110
statistics.py
|
@ -249,6 +249,9 @@ def GetStat_class_view(diction):
|
|||
tmp_val['nb_view'] = str(result['count'])
|
||||
insertObject.append(JSONEncoder().encode(tmp_val))
|
||||
|
||||
tmp_val2 = {}
|
||||
tmp_val2['data'] = "21, 35, 75, 51, 41, 47"
|
||||
insertObject.append(JSONEncoder().encode(tmp_val2))
|
||||
# print(result)
|
||||
|
||||
return True, insertObject
|
||||
|
@ -318,8 +321,25 @@ def GetStat_class_view_topX(diction):
|
|||
topX = mycommon.tryInt(diction['topX'])
|
||||
|
||||
|
||||
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()
|
||||
|
||||
day_before = new_end_date - timedelta(days=0)
|
||||
tmp = 0
|
||||
|
||||
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)+","
|
||||
print(" day_before DATE = " + str(day_before)+ " VS "+str(new_from_date))
|
||||
|
||||
categories['categories'] = str(categories_val)
|
||||
# Verification de la validité du token
|
||||
'''
|
||||
Important : pour créer une formation, il faut obligatoirement avoir un token.
|
||||
|
@ -387,47 +407,46 @@ def GetStat_class_view_topX(diction):
|
|||
{
|
||||
'$group': {
|
||||
'_id': {
|
||||
"Date_view": {"$substr": ["$date_update", 0, SUBSTR]},
|
||||
"INTERNAL URL": "$internal_url",
|
||||
"OWNER": "$owner",
|
||||
"Date_view": {"$substr": ["$date_update", 0, SUBSTR]},
|
||||
|
||||
},
|
||||
'count': {'$count': {}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$sort": {"count": -1}
|
||||
"$sort": {"_id": 1}
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
print(" PIP 2 ="+str(pipe2))
|
||||
for result in collection.aggregate(pipe2):
|
||||
print(str(result['_id']) + " ===> " + str(result['count']))
|
||||
|
||||
|
||||
insertObject = []
|
||||
for result in collection.aggregate(pipe2):
|
||||
tmp_val = {}
|
||||
i = 0
|
||||
for tmp in liste_formation :
|
||||
i = i +1
|
||||
print(" Traitement de "+str(tmp))
|
||||
ret_val = {}
|
||||
ret_val['name'+str(i)] = tmp
|
||||
name = tmp
|
||||
tab_valeur = []
|
||||
for result in collection.aggregate(pipe2):
|
||||
print(str(result['_id'])+" ===> "+str(result['count']))
|
||||
if( name in result['_id']['INTERNAL URL']):
|
||||
print(" OKKKKKKKKKKKKKKKKKKKK ")
|
||||
tab_valeur.append(str(result['count']))
|
||||
|
||||
# tab_training_id.append(str(result["_id"]))
|
||||
# print(result['_id'])
|
||||
ret_val['data'+str(i)] = tab_valeur
|
||||
print(" valll = "+str(ret_val))
|
||||
insertObject.append(JSONEncoder().encode(ret_val))
|
||||
|
||||
if ("Date_view" in result['_id'].keys()):
|
||||
if result['_id']['Date_view']:
|
||||
print("Date_view = " + str(result['_id']['Date_view']))
|
||||
tmp_val['Date_view'] = str(result['_id']['Date_view'])
|
||||
|
||||
if ("OWNER" in result['_id'].keys()):
|
||||
if result['_id']['OWNER']:
|
||||
print("Owner = " + str(result['_id']['OWNER']))
|
||||
tmp_val['owner'] = str(result['_id']['OWNER'])
|
||||
|
||||
if ("INTERNAL URL" in result['_id'].keys()):
|
||||
if result['_id']['INTERNAL URL']:
|
||||
print("INTERNAL URL = " + str(result['_id']['INTERNAL URL']))
|
||||
tmp_val['internal_url'] = str(result['_id']['INTERNAL URL'])
|
||||
|
||||
print("Nombre = " + str(result['count']))
|
||||
tmp_val['nb_view'] = str(result['count'])
|
||||
insertObject.append(JSONEncoder().encode(tmp_val))
|
||||
insertObject.append(JSONEncoder().encode(categories))
|
||||
|
||||
# print(result)
|
||||
|
||||
|
@ -528,9 +547,50 @@ def Get_X_Best_Class_On_Given_period(diction):
|
|||
|
||||
|
||||
return True, insertObject
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de X les formations les plus vue"
|
||||
|
||||
|
||||
|
||||
def test_return():
|
||||
|
||||
try:
|
||||
insertObject = []
|
||||
nb_val ={'nb_formation':'2'}
|
||||
tmp_val0 = {}
|
||||
tmp_val1 = {}
|
||||
tmp_val2 = {}
|
||||
tmp_val3 = {}
|
||||
tmp_val4 = {}
|
||||
|
||||
tmp_val0['categories'] = "01/02/22, 02/02/22, 03/02/22, 04/02/22, 05/02/22, 06/02/22"
|
||||
tmp_val1 = {'name': 'formation 1', 'Date_view': '2022-09-11', 'count':'2'}
|
||||
tmp_val2 = {'name': 'formation 1', 'Date_view': '2022-09-10', 'count': '23'}
|
||||
tmp_val3 = {'name': 'formation 1', 'Date_view': '2022-09-05', 'count': '9'}
|
||||
|
||||
tmp_val4 = {'name': 'formation 2', 'Date_view': '2022-09-11', 'count': '3'}
|
||||
tmp_val5 = {'name': 'formation 2', 'Date_view': '2022-09-10', 'count': '4'}
|
||||
tmp_val6 = {'name': 'formation 3', 'Date_view': '2022-09-05', 'count': '6'}
|
||||
|
||||
|
||||
|
||||
#insertObject.append(JSONEncoder().encode(nb_val))
|
||||
|
||||
insertObject.append(JSONEncoder().encode(tmp_val0))
|
||||
insertObject.append(JSONEncoder().encode(tmp_val1))
|
||||
insertObject.append(JSONEncoder().encode(tmp_val2))
|
||||
insertObject.append(JSONEncoder().encode(tmp_val3))
|
||||
insertObject.append(JSONEncoder().encode(tmp_val4))
|
||||
insertObject.append(JSONEncoder().encode(tmp_val5))
|
||||
insertObject.append(JSONEncoder().encode(tmp_val6))
|
||||
|
||||
|
||||
return True, insertObject
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de test_return"
|
||||
|
||||
|
|
Loading…
Reference in New Issue