Private
Public Access
1
0

test type plannedsessions now have a ranking

This commit is contained in:
Sander Roosendaal
2018-02-15 16:32:33 +01:00
parent 706ffc90fd
commit 2221a633b1
10 changed files with 228 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ import numpy as np
import dataprep
# Low Level functions - to be called by higher level methods
def add_workouts_plannedsession(ws,ps):
def add_workouts_plannedsession(ws,ps,r):
result = 0
comments = []
errors = []
@@ -36,6 +36,20 @@ def add_workouts_plannedsession(ws,ps):
if (not all(d == dates[0] for d in dates)) and ps.sessiontype not in ['challenge','cycletarget']:
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
return result,comments,errors
if len(ws)>1 and ps.sessiontype == 'test':
errors.append('For tests, you can only attach one workout')
return result,comments,errors
wold = Workout.objects.filter(plannedsession=ps,user=r)
ids = [w.id for w in wold] + [w.id for w in ws]
ids = list(set(ids))
if len(ids)>1 and ps.sessiontype == 'test':
errors.append('For tests, you can only attach one workout')
return result,comments,errors
# start adding sessions
for w in ws:
@@ -99,7 +113,7 @@ def get_session_metrics(ps):
rscorev += dataprep.workout_rscore(w)[0]
ratio,statusv = is_session_complete_ws(ws,ps)
completedatev = ws[0].date.strftime('%Y-%b-%d')
completedatev = ws[0].date.strftime('%Y-%m-%d')
durationv /= 60.
trimp.append(int(trimpv))