diff --git a/rowers/datautils.py b/rowers/datautils.py index bff11450..7f8c1af4 100644 --- a/rowers/datautils.py +++ b/rowers/datautils.py @@ -452,7 +452,7 @@ def getfastest(df,thevalue,mode='distance'): starttime = griddata(restime,starttimes,[thevalue*60*1000],method='linear',rescale=True) duration = griddata(restime,restime,[thevalue*60*1000],method='linear',rescale=True) endtime = starttime+duration - #print(distance,starttime,endtime ) + print(distance,starttime,endtime ) return distance[0],starttime[0]/1000.,endtime[0]/1000. return 0 diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 23b9f239..cf8537b5 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -371,7 +371,7 @@ def add_workouts_plannedsession(ws,ps,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 in ['test','coursetest','race','fastest_distance','fastest_time']: + if len(ids)>1 and ps.sessiontype in ['test','coursetest','race']: errors.append('For tests, you can only attach one workout') return result,comments,errors @@ -1571,19 +1571,6 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False): enddatetime ) - # check if all sessions have same date - dates = [w.date for w in ws] - if (not all(d == dates[0] for d in dates)) and race.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,0 - - - if len(ws)>1 and race.sessiontype == 'test': - errors.append('For tests, you can only attach one workout') - return result,comments,errors,0 - - - ids = [w.id for w in ws] ids = list(set(ids)) @@ -1671,7 +1658,7 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False): record.workoutid = ws[0].id if race.sessiontype == 'fastest_distance': df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[ws[0].id]) - fastest_milliseconds = datautils.getfastest(df,race.sessionvalue,mode='distance') + fastest_milliseconds,startsecond,endsecond = datautils.getfastest(df,race.sessionvalue,mode='distance') velo = race.sessionvalue/fastest_milliseconds points = 100.*velo/record.referencespeed @@ -1681,10 +1668,12 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False): record.duration = duration record.distance = race.sessionvalue record.points = points + record.startsecond = startsecond + record.endsecond = endsecond record.save() if race.sessiontype == 'fastest_time': df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[ws[0].id]) - fastest_meters = datautils.getfastest(df,race.sessionvalue,mode='time') + fastest_meters, startsecond, endsecond = datautils.getfastest(df,race.sessionvalue,mode='time') velo = fastest_meters/(60.*race.sessionvalue) points = 100.*velo/record.referencespeed @@ -1694,6 +1683,8 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False): record.distance = fastest_meters record.coursecompleted = True record.points = points + record.startsecond = startsecond + record.endsecond = endsecond record.save() diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index 7bc085de..11257fb3 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -322,8 +322,19 @@