Private
Public Access
1
0

working on low level plannedsession

This commit is contained in:
Sander Roosendaal
2018-02-05 13:49:59 +01:00
parent 92d69087cf
commit a60bba671e
5 changed files with 103 additions and 6 deletions

View File

@@ -20,20 +20,76 @@ from rowers.models import (
TrainingPlan,
)
import metrics
import numpy as np
import dataprep
# Low Level functions - to be called by higher level methods
# dummies for now
def submit_workout(w,ps):
def add_workouts_plannedsession(ws,ps):
for w in ws:
w.plannedsession = ps
w.save()
return 1
def remove_workout_plannedsession(w,ps):
return 1
if w.plannedsession == ps:
w.plannedsession = None
w.save()
return 1
return 0
def clone_planned_session(ps):
ps.save()
ps.pk = None # creates new instance
ps.save()
def timefield_to_seconds_duration(t):
duration = t.hour*3600.
duration += t.minute * 60.
duration += t.second
duration += t.microsecond/1.e6
return duration
def is_session_complete(ps):
ws = Workout.objects.filter(plannedsession=ps)
score = 0
for w in ws:
if ps.sessionmode == 'distance':
score += w.distance
elif ps.sessionmode == 'time':
durationseconds = timefield_to_seconds_duration(w.duration)
score += durationseconds
elif ps.sessionmode == 'TRIMP':
trimp = dataprep.workout_trimp(w)
score += trimp
elif ps.sessionmode == 'rScore':
rscore = dataprep.workout_rscore(w)
score += rscore
ratio = score/float(ps.value)
if ratio>0.8 and ratio<1.2:
return True
return False
def rank_results(ps):
return 1
def add_team(t,ps):
ps.team.add(t)
ps.save()
return 1
def add_rower(r,ps):
ps.rower.add(r)
ps.save()
return 1