some more logging
This commit is contained in:
@@ -102,9 +102,9 @@ def strokedatajson_v2(request,id):
|
|||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
columns = ['spm','time','hr','pace','power','distance']
|
columns = ['spm','time','hr','pace','power','distance']
|
||||||
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
||||||
with open('media/apilog.log','a') as logfile:
|
with open('apilog.log','a') as logfile:
|
||||||
logfile.write(str(timezone.now())+": ")
|
logfile.write(str(timezone.now())+": ")
|
||||||
logfile.write(request.user.username+"(GET) \n")
|
logfile.write(request.user.username+"(strokedatajson_v2 GET) \n")
|
||||||
|
|
||||||
data = datadf.to_json(orient='records')
|
data = datadf.to_json(orient='records')
|
||||||
data2 = json.loads(data)
|
data2 = json.loads(data)
|
||||||
@@ -113,10 +113,18 @@ def strokedatajson_v2(request,id):
|
|||||||
return JSONResponse(data2)
|
return JSONResponse(data2)
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
with open('media/apilog.log','a') as logfile:
|
with open('apilog.log','a') as logfile:
|
||||||
print(str(timezone.now()))
|
|
||||||
logfile.write(str(timezone.now())+": ")
|
logfile.write(str(timezone.now())+": ")
|
||||||
logfile.write(request.user.username+"(POST) \n")
|
logfile.write(request.user.username+"(strokedatajson_v2 POST) \n")
|
||||||
|
try:
|
||||||
|
logfile.write(request.data['data']+"\n")
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
logfile.write(request.data['strokedata']+"\n")
|
||||||
|
except KeyError:
|
||||||
|
logfile.write("No data in request.data\n")
|
||||||
|
except AttributeError:
|
||||||
|
logfile.write("No data in request\n")
|
||||||
checkdata, r = dataprep.getrowdata_db(id=row.id)
|
checkdata, r = dataprep.getrowdata_db(id=row.id)
|
||||||
if not checkdata.empty:
|
if not checkdata.empty:
|
||||||
return HttpResponse("Duplicate Error",status=409)
|
return HttpResponse("Duplicate Error",status=409)
|
||||||
@@ -246,9 +254,9 @@ def strokedatajson_v2(request,id):
|
|||||||
starttime = totimestamp(row.startdatetime)+time[0]
|
starttime = totimestamp(row.startdatetime)+time[0]
|
||||||
unixtime = starttime+time
|
unixtime = starttime+time
|
||||||
|
|
||||||
with open('media/apilog.log','a') as logfile:
|
with open('apilog.log','a') as logfile:
|
||||||
logfile.write(str(starttime)+": ")
|
logfile.write(str(starttime)+": ")
|
||||||
logfile.write(request.user.username+"(POST) \r\n")
|
logfile.write(request.user.username+"(strokedatajson_v2 POST) \r\n")
|
||||||
|
|
||||||
|
|
||||||
data = pd.DataFrame({'TimeStamp (sec)':unixtime,
|
data = pd.DataFrame({'TimeStamp (sec)':unixtime,
|
||||||
@@ -337,17 +345,15 @@ def strokedatajson(request,id):
|
|||||||
# currently only returns a subset.
|
# currently only returns a subset.
|
||||||
columns = ['spm','time','hr','pace','power','distance']
|
columns = ['spm','time','hr','pace','power','distance']
|
||||||
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
||||||
with open('media/apilog.log','a') as logfile:
|
with open('apilog.log','a') as logfile:
|
||||||
print(str(timezone.now()))
|
|
||||||
logfile.write(str(timezone.now())+": ")
|
logfile.write(str(timezone.now())+": ")
|
||||||
logfile.write(request.user.username+"(GET) \n")
|
logfile.write(request.user.username+"(strokedatajson GET) \n")
|
||||||
return JSONResponse(datadf)
|
return JSONResponse(datadf)
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
with open('media/apilog.log','a') as logfile:
|
with open('apilog.log','a') as logfile:
|
||||||
print(str(timezone.now()))
|
|
||||||
logfile.write(str(timezone.now())+": ")
|
logfile.write(str(timezone.now())+": ")
|
||||||
logfile.write(request.user.username+"(POST) \n")
|
logfile.write(request.user.username+"(strokedatjson POST) \n")
|
||||||
checkdata,r = dataprep.getrowdata_db(id=row.id)
|
checkdata,r = dataprep.getrowdata_db(id=row.id)
|
||||||
if not checkdata.empty:
|
if not checkdata.empty:
|
||||||
return HttpResponse("Duplicate Error",status=409)
|
return HttpResponse("Duplicate Error",status=409)
|
||||||
@@ -402,7 +408,7 @@ def strokedatajson(request,id):
|
|||||||
starttime = totimestamp(row.startdatetime)+time[0]
|
starttime = totimestamp(row.startdatetime)+time[0]
|
||||||
unixtime = starttime+time
|
unixtime = starttime+time
|
||||||
|
|
||||||
with open('media/apilog.log','a') as logfile:
|
with open('apilog.log','a') as logfile:
|
||||||
logfile.write(str(starttime)+": ")
|
logfile.write(str(starttime)+": ")
|
||||||
logfile.write(request.user.username+"(POST) \r\n")
|
logfile.write(request.user.username+"(POST) \r\n")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user