Private
Public Access
1
0

logging of API usage

This commit is contained in:
Sander Roosendaal
2017-07-03 12:03:36 +02:00
parent e69239f2e3
commit a5bedb4a93
3 changed files with 10 additions and 2 deletions

View File

@@ -816,7 +816,7 @@ def new_workout_from_df(r,df,
timestr = strftime("%Y%m%d-%H%M%S") timestr = strftime("%Y%m%d-%H%M%S")
csvfilename ='media/Fusion_'+timestr+'.csv' csvfilename ='media/df_'+timestr+'.csv'
df.rename(columns = columndict,inplace=True) df.rename(columns = columndict,inplace=True)

View File

@@ -146,7 +146,7 @@ USER_LANGUAGE = 'en-US'
from interactiveplots import * from interactiveplots import *
# Define the API documentation # Define the API documentation
schema_view = get_swagger_view(title='Rowsandall API (Unstable)') schema_view = get_swagger_view(title='Rowsandall API')
# Custom error pages with Rowsandall headers # Custom error pages with Rowsandall headers
def error500_view(request): def error500_view(request):
@@ -7985,6 +7985,9 @@ 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:
logfile.write(str(timezone.now())+": ")
logfile.write(request.user.username+"(GET) \n")
return JSONResponse(datadf) return JSONResponse(datadf)
if request.method == 'POST': if request.method == 'POST':
@@ -8033,6 +8036,10 @@ def strokedatajson(request,id):
starttime = totimestamp(row.startdatetime)+time starttime = totimestamp(row.startdatetime)+time
unixtime = starttime+time unixtime = starttime+time
with open('media/apilog.log','a') as logfile:
logfile.write(starttime+": ")
logfile.write(request.user.username+"(POST) \r\n")
data = pd.DataFrame({'TimeStamp (sec)':unixtime, data = pd.DataFrame({'TimeStamp (sec)':unixtime,
' Horizontal (meters)': distance, ' Horizontal (meters)': distance,
' Cadence (stokes/min)':spm, ' Cadence (stokes/min)':spm,
@@ -8049,6 +8056,7 @@ def strokedatajson(request,id):
' ElapsedTime (sec)':time, ' ElapsedTime (sec)':time,
}) })
# Following part should be replaced with dataprep.new_workout_from_df
timestr = row.startdatetime.strftime("%Y%m%d-%H%M%S") timestr = row.startdatetime.strftime("%Y%m%d-%H%M%S")
csvfilename ='media/Import_'+timestr+'.csv' csvfilename ='media/Import_'+timestr+'.csv'

Binary file not shown.