ds
This commit is contained in:
@@ -15,6 +15,7 @@ from rest_framework.decorators import parser_classes
|
||||
from rest_framework.parsers import BaseParser
|
||||
|
||||
from rowers.utils import geo_distance
|
||||
from rowers.dataflow import upload_handler
|
||||
|
||||
from datetime import datetime as dt
|
||||
|
||||
@@ -467,7 +468,6 @@ def strokedata_rowingdata(request):
|
||||
filename, completefilename = handle_uploaded_file(f)
|
||||
|
||||
uploadoptions = {
|
||||
'secret': settings.UPLOAD_SERVICE_SECRET,
|
||||
'user': r.user.id,
|
||||
'file': completefilename,
|
||||
'workouttype': form.cleaned_data['workouttype'],
|
||||
@@ -477,17 +477,21 @@ def strokedata_rowingdata(request):
|
||||
'notes': form.cleaned_data['notes']
|
||||
}
|
||||
|
||||
url = settings.UPLOAD_SERVICE_URL
|
||||
result = upload_handler(uploadoptions, completefilename, createworkout=True)
|
||||
if result['status'] != 'processing':
|
||||
dologging('apilog.log','Error in strokedata_rowingdata:')
|
||||
dologging('apilog.log',result)
|
||||
return JsonResponse(
|
||||
result,
|
||||
status=500
|
||||
)
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_request_post,
|
||||
url,
|
||||
uploadoptions)
|
||||
workoutid = result.get('job_id',0)
|
||||
response = JsonResponse(
|
||||
{
|
||||
"status": "success",
|
||||
}
|
||||
)
|
||||
{"workout public id": workoutid,
|
||||
"status": "success",
|
||||
}
|
||||
)
|
||||
response.status_code = 201
|
||||
return response
|
||||
|
||||
@@ -518,7 +522,6 @@ def strokedata_rowingdata_apikey(request):
|
||||
filename, completefilename = handle_uploaded_file(f)
|
||||
|
||||
uploadoptions = {
|
||||
'secret': settings.UPLOAD_SERVICE_SECRET,
|
||||
'user': r.user.id,
|
||||
'file': completefilename,
|
||||
'workouttype': form.cleaned_data['workouttype'],
|
||||
@@ -528,17 +531,22 @@ def strokedata_rowingdata_apikey(request):
|
||||
'notes': form.cleaned_data['notes']
|
||||
}
|
||||
|
||||
url = settings.UPLOAD_SERVICE_URL
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_request_post,
|
||||
url,
|
||||
uploadoptions)
|
||||
result = upload_handler(uploadoptions, completefilename, createworkout=True)
|
||||
|
||||
if result['status'] != 'processing':
|
||||
dologging('apilog.log','Error in strokedata_rowingdata_apikey:')
|
||||
dologging('apilog.log',result)
|
||||
return JsonResponse(
|
||||
result,
|
||||
status=500
|
||||
)
|
||||
workoutid = result.get('job_id',0)
|
||||
response = JsonResponse(
|
||||
{
|
||||
"status": "success",
|
||||
}
|
||||
)
|
||||
{"workout public id": workoutid,
|
||||
"status": "success",
|
||||
}
|
||||
)
|
||||
|
||||
response.status_code = 201
|
||||
return response
|
||||
|
||||
@@ -614,7 +622,6 @@ def strokedata_fit(request):
|
||||
)
|
||||
|
||||
uploadoptions = {
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
'user': request.user.id,
|
||||
'file': fit_filename,
|
||||
'boattype': '1x',
|
||||
@@ -626,20 +633,18 @@ def strokedata_fit(request):
|
||||
'offline': False,
|
||||
}
|
||||
|
||||
url = UPLOAD_SERVICE_URL
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_request_post,
|
||||
url,
|
||||
uploadoptions)
|
||||
result = upload_handler(uploadoptions, fit_filename)
|
||||
|
||||
dologging('apilog.log','FIT file uploaded, returning response')
|
||||
returndict = {
|
||||
"status": "success",
|
||||
"workout public id": encoder.encode_hex(w.id),
|
||||
"workout id": w.id,
|
||||
}
|
||||
return JsonResponse(returndict, status=201)
|
||||
if result.get('status','') != 'processing':
|
||||
return JsonResponse(result, status=500)
|
||||
|
||||
workoutid = result.get('job_id',0)
|
||||
return JsonResponse(
|
||||
{"workout public id": workoutid,
|
||||
"status": "success",
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
dologging('apilog.log','FIT API endpoint')
|
||||
dologging('apilog.log',e)
|
||||
@@ -736,7 +741,6 @@ def strokedata_tcx(request):
|
||||
# need workouttype, duration
|
||||
|
||||
uploadoptions = {
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
'user': request.user.id,
|
||||
'file': tcxfilename,
|
||||
'id': w.id,
|
||||
@@ -747,17 +751,15 @@ def strokedata_tcx(request):
|
||||
'notes': '',
|
||||
'offline': False,
|
||||
}
|
||||
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_post_workout_api,
|
||||
uploadoptions)
|
||||
|
||||
workoutid = w.id
|
||||
result = upload_handler(uploadoptions, tcxfilename)
|
||||
if result.get('status','') != 'processing':
|
||||
return JsonResponse(result, status=500)
|
||||
|
||||
workoutid = result.get('job_id',0)
|
||||
|
||||
return JsonResponse(
|
||||
{"workout public id": encoder.encode_hex(workoutid),
|
||||
"workout id": workoutid,
|
||||
{"workout public id": workoutid,
|
||||
"status": "success",
|
||||
})
|
||||
except Exception as e: # pragma: no cover
|
||||
@@ -884,7 +886,6 @@ def strokedatajson_v3(request):
|
||||
w.save()
|
||||
|
||||
uploadoptions = {
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
'user': request.user.id,
|
||||
'file': csvfilename,
|
||||
'title': title,
|
||||
@@ -898,10 +899,9 @@ def strokedatajson_v3(request):
|
||||
'id': w.id,
|
||||
}
|
||||
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_post_workout_api,
|
||||
uploadoptions)
|
||||
result = upload_handler(uploadoptions, csvfilename)
|
||||
if result.get('status','') != 'processing':
|
||||
return JsonResponse(result, status=500)
|
||||
|
||||
workoutid = w.id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user