updates on api
This commit is contained in:
@@ -2507,7 +2507,7 @@ def read_df_sql(id):
|
||||
try:
|
||||
f = 'media/strokedata_{id}.parquet.gz'.format(id=id)
|
||||
df = pd.read_parquet(f)
|
||||
except (OSError,ArrowInvalid):
|
||||
except (OSError,ArrowInvalid,IndexError):
|
||||
rowdata,row = getrowdata(id=id)
|
||||
if rowdata and len(rowdata.df):
|
||||
data = dataprep(rowdata.df,id=id,bands=True,otwpower=True,barchart=True)
|
||||
|
||||
@@ -227,6 +227,8 @@
|
||||
<p>
|
||||
<ul class="contentli">
|
||||
<li><b>power</b>: Power (Watt)</li>
|
||||
<li><b>latitude</b>: GPS position (latitude)</li>
|
||||
<li><b>longitude</b>: GPS position (longitude)</li>
|
||||
<li><b>drivelength</b>: Drive length (meters)</li>
|
||||
<li><b>dragfactor</b>: Drag factor</li>
|
||||
<li><b>drivetime</b>: Drive time (ms)</li>
|
||||
|
||||
@@ -111,6 +111,10 @@ def strokedatajson_v2(request,id):
|
||||
return JSONResponse(data)
|
||||
|
||||
if request.method == 'POST':
|
||||
with open('media/apilog.log','a') as logfile:
|
||||
print(str(timezone.now()))
|
||||
logfile.write(str(timezone.now())+": ")
|
||||
logfile.write(request.user.username+"(POST) \n")
|
||||
checkdata, r = dataprep.getrowdata_db(id=row.id)
|
||||
if not checkdata.empty:
|
||||
return HttpResponse("Duplicate Error",status=409)
|
||||
@@ -226,6 +230,15 @@ def strokedatajson_v2(request,id):
|
||||
except KeyError:
|
||||
hr = 0*df['time']
|
||||
|
||||
try:
|
||||
latitude = df['latitude']
|
||||
except KeyError:
|
||||
latitude = 0*df['time']
|
||||
|
||||
try:
|
||||
longitude = df['longitude']
|
||||
except KeyError:
|
||||
longitude = 0*df['time']
|
||||
|
||||
|
||||
starttime = totimestamp(row.startdatetime)+time[0]
|
||||
@@ -256,6 +269,8 @@ def strokedatajson_v2(request,id):
|
||||
'wash':wash,
|
||||
'driveenergy':driveenergy,
|
||||
'peakforceangle':peakforceangle,
|
||||
' latitude': latitude,
|
||||
' longitude': longitude,
|
||||
})
|
||||
|
||||
r = getrower(request.user)
|
||||
@@ -286,7 +301,12 @@ def strokedatajson_v2(request,id):
|
||||
datadf = dataprep.dataprep(rowdata,id=row.id,bands=True,barchart=True,otwpower=True,empower=True)
|
||||
|
||||
|
||||
return(HttpResponse(encoder.encode_hex(row.id),status=201))
|
||||
return(JsonResponse(
|
||||
{"workout public id":encoder.encode_hex(row.id),
|
||||
"workout private id":row.id,
|
||||
"status":"success",
|
||||
}))
|
||||
#return(HttpResponse(encoder.encode_hex(row.id),status=201))
|
||||
|
||||
return HttpResponseNotAllowed("Method not supported")
|
||||
|
||||
@@ -316,11 +336,16 @@ def strokedatajson(request,id):
|
||||
columns = ['spm','time','hr','pace','power','distance']
|
||||
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
||||
with open('media/apilog.log','a') as logfile:
|
||||
print(str(timezone.now()))
|
||||
logfile.write(str(timezone.now())+": ")
|
||||
logfile.write(request.user.username+"(GET) \n")
|
||||
return JSONResponse(datadf)
|
||||
|
||||
if request.method == 'POST':
|
||||
with open('media/apilog.log','a') as logfile:
|
||||
print(str(timezone.now()))
|
||||
logfile.write(str(timezone.now())+": ")
|
||||
logfile.write(request.user.username+"(POST) \n")
|
||||
checkdata,r = dataprep.getrowdata_db(id=row.id)
|
||||
if not checkdata.empty:
|
||||
return HttpResponse("Duplicate Error",status=409)
|
||||
|
||||
Reference in New Issue
Block a user