analysis split
This commit is contained in:
@@ -4073,6 +4073,43 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec,
|
||||
|
||||
return workoutid
|
||||
|
||||
@app.task
|
||||
def handle_split_workout_by_intervals(id, debug=False, **kwargs):
|
||||
row = Workout.objects.get(id=id)
|
||||
r = row.user
|
||||
rowdata = rdata(csvfile=row.csvfilename)
|
||||
if rowdata == 0:
|
||||
messages.error(request,"No Data file found for this workout")
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
new_rowdata = rowdata.split_by_intervals()
|
||||
interval_i = 1
|
||||
for data in new_rowdata:
|
||||
filename = 'media/{code}.csv'.format(
|
||||
code = uuid4() .hex[:16]
|
||||
)
|
||||
|
||||
data.write_csv(filename)
|
||||
|
||||
uploadoptions = {
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
'user': r.user.id,
|
||||
'title': '{title} - interval {i}'.format(title=row.name, i=interval_i),
|
||||
'file': filename,
|
||||
'boattype': row.boattype,
|
||||
'workouttype': row.workouttype,
|
||||
}
|
||||
|
||||
session = requests.session()
|
||||
newHeaders = {'Content-type': 'application/json', 'Accept': 'text/plan'}
|
||||
session.headers.update(newHeaders)
|
||||
response = session.post(UPLOAD_SERVICE_URL, json=uploadoptions)
|
||||
|
||||
interval_i = interval_i + 1
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
@app.task
|
||||
def fetch_rojabo_session(id,alldata,userid,rowerid,debug=False, **kwargs): # pragma: no cover
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user