api v3 latency related improvements
This commit is contained in:
@@ -296,6 +296,10 @@ def strokedatajson_v3(request):
|
||||
|
||||
csvfilename = 'media/{code}.csv.gz'.format(code=uuid4().hex[:16])
|
||||
_ = data.to_csv(csvfilename, index_label='index', compression='gzip')
|
||||
|
||||
duration = datetime.time(0,0,1)
|
||||
w = Workout(user=request.user.rower,date=timezone.now().date(),duration=duration)
|
||||
w.save()
|
||||
|
||||
uploadoptions = {
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
@@ -309,20 +313,15 @@ def strokedatajson_v3(request):
|
||||
'rpe': rpe,
|
||||
'notes': notes,
|
||||
'timezone': timeZone,
|
||||
'id': w.id,
|
||||
}
|
||||
session = requests.session()
|
||||
newHeaders = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||
session.headers.update(newHeaders)
|
||||
|
||||
response = session.post(UPLOAD_SERVICE_URL, json=uploadoptions)
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_post_workout_api,
|
||||
uploadoptions)
|
||||
|
||||
if response.status_code != 200:
|
||||
return HttpResponse(response.text, response.status_code)
|
||||
|
||||
try:
|
||||
workoutid = response.json()['id']
|
||||
except KeyError:
|
||||
workoutid = 1
|
||||
workoutid = w.id
|
||||
|
||||
return JsonResponse(
|
||||
{"workout public id": encoder.encode_hex(workoutid),
|
||||
|
||||
@@ -242,6 +242,7 @@ from rowers.rows import handle_uploaded_file, handle_uploaded_image
|
||||
from rowers.plannedsessions import *
|
||||
from rowers.tasks import handle_makeplot, handle_otwsetpower, handle_sendemailtcx, handle_sendemailcsv
|
||||
from rowers.tasks import (
|
||||
handle_post_workout_api,
|
||||
handle_sendemail_newftp,
|
||||
instroke_static,
|
||||
fetch_rojabo_session,
|
||||
|
||||
@@ -5210,6 +5210,7 @@ def workout_upload_api(request):
|
||||
|
||||
# sync related IDs
|
||||
c2id = post_data.get('c2id', '')
|
||||
workoutid = post_data.get('id','')
|
||||
|
||||
startdatetime = post_data.get('startdatetime', '')
|
||||
oarlockfirmware = post_data.get('oarlockfirmware', None)
|
||||
@@ -5300,6 +5301,7 @@ def workout_upload_api(request):
|
||||
inboard=inboard,
|
||||
oarlength=oarlength,
|
||||
impeller=useImpeller,
|
||||
workoutid=workoutid,
|
||||
)
|
||||
|
||||
if id == 0: # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user