From 7d7c376b2a2775682d70b7021d81629683ebce71 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 14 Feb 2018 21:50:11 +0100 Subject: [PATCH 1/4] changed completion criteria for approximate cycletarget --- rowers/plannedsessions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 449de9e1..333ce0c3 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -170,7 +170,9 @@ def is_session_complete_ws(ws,ps): else: return ratio,'partial' else: - if ratio>0.8 and ratio<1.2: + if ratio>0.8 and ratio<1.2 and ps.sessiontype=='session': + return ratio,'completed' + elif ratio>0.95 and ratio<1.1 and ps.sessiontype=='cycletarget': return ratio,'completed' else: return ratio,'partial' From f1f28650f6b4c6c25948edf8d516d626cc4ff51f Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 14 Feb 2018 21:59:01 +0100 Subject: [PATCH 2/4] updated criteria after the committee decided --- rowers/plannedsessions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 333ce0c3..aaf54676 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -165,14 +165,14 @@ def is_session_complete_ws(ws,ps): else: return ratio,'partial' elif ps.criterium == 'minimum': - if ratio > 1.0: + if ratio >= 1.0: return ratio,'completed' else: return ratio,'partial' else: if ratio>0.8 and ratio<1.2 and ps.sessiontype=='session': return ratio,'completed' - elif ratio>0.95 and ratio<1.1 and ps.sessiontype=='cycletarget': + elif ratio>0.9167 and ratio<1.0833 and ps.sessiontype=='cycletarget': return ratio,'completed' else: return ratio,'partial' From 706ffc90fdd8b6d10cfb84093ba88bc0b66bfa34 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 15 Feb 2018 08:52:40 +0100 Subject: [PATCH 3/4] changed startdate, time ordering to startdatetime ordering in join --- rowers/dataprep.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 4ff0fe18..48f4556d 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -195,7 +195,7 @@ def join_workouts(r,ids,title='Joined Workout', # reorder in chronological order - ws = Workout.objects.filter(id__in=ids).order_by("date", "starttime") + ws = Workout.objects.filter(id__in=ids).order_by("startdatetime") if not parent: parent = ws[0] From 2221a633b1bb01f1a972f2c8b6f7673c3d1664fa Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 15 Feb 2018 16:32:33 +0100 Subject: [PATCH 4/4] test type plannedsessions now have a ranking --- rowers/models.py | 13 +++- rowers/plannedsessions.py | 18 ++++- rowers/templates/.#list_workouts.html | 1 + rowers/templates/plannedsessioncreate.html | 2 + rowers/templates/plannedsessionedit.html | 2 + .../templates/plannedsessionteamcreate.html | 70 +++++++++++++++++++ rowers/templates/plannedsessionteamedit.html | 70 +++++++++++++++++++ rowers/templates/plannedsessionview.html | 27 +++++++ rowers/urls.py | 2 + rowers/views.py | 31 ++++++-- 10 files changed, 228 insertions(+), 8 deletions(-) create mode 100644 rowers/templates/.#list_workouts.html diff --git a/rowers/models.py b/rowers/models.py index b62f0f78..6d380cc2 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -825,7 +825,6 @@ class PlannedSession(models.Model): sessionunitchoices = ( ('min','minutes'), - ('km','km'), ('m','meters'), ('None',None), ) @@ -904,7 +903,17 @@ class PlannedSession(models.Model): self.sessionunit = 'min' else: self.sessionunit = 'None' - + + if self.sessiontype == 'test': + if self.sessionmode not in ['distance','time']: + if self.sessionvalue < 100: + self.sessionmode = 'time' + self.sessionunit = 'min' + else: + self.sessionmode = 'distance' + self.sessionunit = 'm' + self.criterium = 'exact' + super(PlannedSession,self).save(*args, **kwargs) # Date input utility diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index aaf54676..aaf15c23 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -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)) diff --git a/rowers/templates/.#list_workouts.html b/rowers/templates/.#list_workouts.html new file mode 100644 index 00000000..656119b2 --- /dev/null +++ b/rowers/templates/.#list_workouts.html @@ -0,0 +1 @@ +e408191@CZ27LT9RCGN72.36632:1518629534 \ No newline at end of file diff --git a/rowers/templates/plannedsessioncreate.html b/rowers/templates/plannedsessioncreate.html index d36fe8e8..6a03f149 100644 --- a/rowers/templates/plannedsessioncreate.html +++ b/rowers/templates/plannedsessioncreate.html @@ -155,6 +155,8 @@ } if (this.value == 'test') { $("td #id_criterium").prop("value","exact"); + $("td #id_sessionmode").prop("value","distance"); + $("td #id_sessionunit").prop("value","m"); } if (this.value == 'challenge') { $("td #id_criterium").prop("value","minimum"); diff --git a/rowers/templates/plannedsessionedit.html b/rowers/templates/plannedsessionedit.html index ff679912..9021105f 100644 --- a/rowers/templates/plannedsessionedit.html +++ b/rowers/templates/plannedsessionedit.html @@ -160,6 +160,8 @@ } if (this.value == 'test') { $("td #id_criterium").prop("value","exact"); + $("td #id_sessionmode").prop("value","distance"); + $("td #id_sessionunit").prop("value","m"); } if (this.value == 'challenge') { $("td #id_criterium").prop("value","minimum"); diff --git a/rowers/templates/plannedsessionteamcreate.html b/rowers/templates/plannedsessionteamcreate.html index 2ecb9a80..24169c2e 100644 --- a/rowers/templates/plannedsessionteamcreate.html +++ b/rowers/templates/plannedsessionteamcreate.html @@ -119,3 +119,73 @@ {% endblock %} + +{% block scripts %} + + +{% endblock %} diff --git a/rowers/templates/plannedsessionteamedit.html b/rowers/templates/plannedsessionteamedit.html index 774a4218..0dbf27b6 100644 --- a/rowers/templates/plannedsessionteamedit.html +++ b/rowers/templates/plannedsessionteamedit.html @@ -135,3 +135,73 @@ {% endblock %} + +{% block scripts %} + + +{% endblock %} diff --git a/rowers/templates/plannedsessionview.html b/rowers/templates/plannedsessionview.html index 96bca094..2ee8c3d6 100644 --- a/rowers/templates/plannedsessionview.html +++ b/rowers/templates/plannedsessionview.html @@ -39,6 +39,33 @@