From 0d7c889caf5e9bd46792ccfb41a947aaa5108b78 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Wed, 10 Jun 2020 19:16:31 +0200
Subject: [PATCH 1/9] requirements.txt
---
requirements.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index d08e1fed..8aba5f9a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -164,7 +164,7 @@ pytest-xdist==1.27.0
python-dateutil==2.8.0
python-memcached==1.59
python-twitter==3.5
-pytz==2018.9
+pytz==2020.1
pyviz-comms==0.7.1
pywin32-ctypes==0.2.0
pywinpty==0.5.5
@@ -173,9 +173,9 @@ pyzmq==18.0.1
qtconsole==4.4.3
ratelim==0.1.6
redis==3.2.1
-requests==2.21.0
+requests==2.23.0
requests-oauthlib==1.2.0
-rowingdata==2.8.4
+rowingdata==2.9.1
rowingphysics==0.5.0
rq==0.13.0
rules==2.1
From ab3a57b7dd8926b4733e562d8cb147ff353f70d9 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 14:14:59 +0200
Subject: [PATCH 2/9] send email when course fails
---
rowers/plannedsessions.py | 6 +-
rowers/tasks.py | 75 ++++++++++++++++++++++-
rowers/templates/trajectoryfailemail.html | 22 +++++++
rowers/views/planviews.py | 4 +-
4 files changed, 102 insertions(+), 5 deletions(-)
create mode 100644 rowers/templates/trajectoryfailemail.html
diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py
index 02df37f3..d8936ca3 100644
--- a/rowers/plannedsessions.py
+++ b/rowers/plannedsessions.py
@@ -381,6 +381,7 @@ def add_workouts_plannedsession(ws,ps,r):
record.save()
job = myqueue(queue,handle_check_race_course,w.csvfilename,
w.id,ps.course.id,record.id,
+ w.user.user.email,w.user.user.first_name,
mode='coursetest')
else:
errors.append('Workout %i did not match session dates' % w.id)
@@ -659,6 +660,7 @@ def is_session_complete_ws(ws,ps):
record.save()
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
ws[0].id,ps.course.id,record.id,
+ ws[0].user.user.email,ws[0].user.user.first_name,
mode='coursetest')
return (0,'not done',None)
@@ -1575,7 +1577,9 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
comments.append('Workouts submitted to virtual events have to be public. We have changed the workout to a public workout.')
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
- ws[0].id,race.course.id,record.id,splitsecond=splitsecond,
+ ws[0].id,race.course.id,record.id,
+ ws[0].user.user.email,ws[0].user.user.first_name,
+ splitsecond=splitsecond,
referencespeed=record.referencespeed,coursedistance=race.course.distance
)
diff --git a/rowers/tasks.py b/rowers/tasks.py
index fcd7bc62..68a33e89 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -119,7 +119,11 @@ siteurl = SITE_URL
# testing task
from rowers.emails import send_template_email
-from rowers.courseutils import coursetime_paths, coursetime_first, time_in_path
+from rowers.courseutils import (
+ coursetime_paths, coursetime_first, time_in_path,
+ InvalidTrajectoryError
+ )
+
@app.task
def add(x, y):
@@ -342,7 +346,8 @@ def polygon_to_path(polygon,debug=True):
@app.task(bind=True)
def handle_check_race_course(self,
f1,workoutid,courseid,
- recordid,**kwargs):
+ recordid,useremail,userfirstname,
+ **kwargs):
if 'debug' in kwargs:
debug = kwargs['debug']
@@ -432,7 +437,15 @@ def handle_check_race_course(self,
paths.append(path)
# check how many times went through start polygon
- entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
+ try:
+ entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
+ except InvalidTrajectoryError:
+ entrytimes = []
+ entrydistances = []
+ coursecompleted = False
+ coursemeters = 0
+ coursetimeseconds = 0
+
cseconds = []
cmeters = []
@@ -528,6 +541,39 @@ def handle_check_race_course(self,
return 1
else:
+ query = 'UPDATE rowers_virtualraceresult SET coursecompleted = 0, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond}, points={points} WHERE id={recordid}'.format(
+ recordid=recordid,
+ duration=totaltime_sec_to_string(0),
+ distance=0),
+ points=0,
+ workoutid=workoutid,
+ startsecond=startsecond,
+ endsecond=endsecond,
+ )
+
+ if mode == 'coursetest':
+ query = 'UPDATE rowers_coursetestresult SET coursecompleted = 0, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond}, points={points} WHERE id={recordid}'.format(
+ recordid=recordid,
+ duration=totaltime_sec_to_string(0),
+ distance=0,
+ points=0,
+ workoutid=workoutid,
+ startsecond=startsecond,
+ endsecond=endsecond,
+ )
+
+
+ with engine.connect() as conn, conn.begin():
+ result = conn.execute(query)
+
+ conn.close()
+ engine.dispose()
+
+ # send email
+ handle_send_email_coursefail(
+ useremail,userfirstname,
+ )
+
return 2
return 0
@@ -1118,6 +1164,29 @@ def handle_sendemail_raceregistration(
return 1
+def handle_sendemail_coursefail(
+ useremail, username, **kwargs):
+
+ if 'debug' in kwargs:
+ debug = kwargs['debug']
+ else:
+ debug = True
+
+ subject = "The validation of your course has failed"
+
+ from_email = 'Rowsandall '
+
+ d = {
+ 'username':username,
+ }
+
+ res = send_template_email(from_email,[useremail],
+ subject,
+ 'trajectoryfailemail.html',
+ d,**kwargs)
+
+ return 1
+
@app.task
def handle_sendemail_optout(
useremail, username, registeredname, racename, raceid, **kwargs):
diff --git a/rowers/templates/trajectoryfailemail.html b/rowers/templates/trajectoryfailemail.html
new file mode 100644
index 00000000..3022682b
--- /dev/null
+++ b/rowers/templates/trajectoryfailemail.html
@@ -0,0 +1,22 @@
+{% extends "emailbase.html" %}
+{% block body %}
+Dear {{ username }},
+
+
+ Unfortunately, the course you took did not go through all gates for
+ the virtual challenge.
+ You can check your course versus the gates by clicking on Details
+ in your challenge result.
+ Of course, you can always submit a new row!
+
+
+
+ If you feel that your course should have been valid, or in case
+ you have questions, please
+ contact me by reply to this email.
+
+
+
+ Best Regards, the Rowsandall Team
+
+{% endblock %}
diff --git a/rowers/views/planviews.py b/rowers/views/planviews.py
index f596d83a..f30b51b9 100644
--- a/rowers/views/planviews.py
+++ b/rowers/views/planviews.py
@@ -1956,7 +1956,9 @@ def plannedsession_view(request,id=0,userid=0):
record.save()
job = myqueue(queue,handle_check_race_course,
w.csvfilename,w.id,ps.course.id,
- record.id,mode='coursetest')
+ record.id,
+ w.user.user.email,w.user.user.first_name,
+ mode='coursetest')
intsecs = 0
microsecs = 0
From 5bb941ce88a9c4eb702e328cc275fd821beae122 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 14:26:12 +0200
Subject: [PATCH 3/9] adding ranking
---
rowers/templates/virtualevent.html | 28 ++++++++++++++++++++++-
rowers/templates/virtualeventranking.html | 28 ++++++++++++++++++++++-
rowers/views/racesviews.py | 11 +++++++++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html
index 90685498..cd3ffd22 100644
--- a/rowers/templates/virtualevent.html
+++ b/rowers/templates/virtualevent.html
@@ -267,7 +267,7 @@
Results
{% endif %}
- {% if results or dns %}
+ {% if results or dns or dnf %}
@@ -349,6 +349,32 @@
{% endfor %}
+ {% for result in dnf %}
+
+ | |
+ {{ result.username }} |
+ {{ result.teamname }} |
+ {{ result.age }} |
+ {{ result.sex }} |
+ {{ result.weightcategory }} |
+
+ {% if result.adaptiveclass == 'None' %}
+
+ {% else %}
+ {{ result.adaptiveclass }}
+ {% endif %}
+ |
+ {{ result.boatclass }} |
+ {% if race.sessiontype == 'race' %}
+ {{ result.boattype }} |
+ {% endif %}
+ DNF |
+
+
+ Details
+ |
+
+ {% endfor %}
{% for result in dns %}
| |
diff --git a/rowers/templates/virtualeventranking.html b/rowers/templates/virtualeventranking.html
index 42bb6299..9053c269 100644
--- a/rowers/templates/virtualeventranking.html
+++ b/rowers/templates/virtualeventranking.html
@@ -48,7 +48,7 @@
Results
{% endif %}
- {% if results or dns %}
+ {% if results or dns or dnf %}
@@ -108,6 +108,32 @@
{% endfor %}
+ {% for result in dnf %}
+
+ | |
+ {{ result.username }} |
+ {{ result.teamname }} |
+ {{ result.age }} |
+ {{ result.sex }} |
+ {{ result.weightcategory }} |
+
+ {% if result.adaptiveclass == 'None' %}
+
+ {% else %}
+ {{ result.adaptiveclass }}
+ {% endif %}
+ |
+ {{ result.boatclass }} |
+ {% if race.sessiontype == 'race' %}
+ {{ result.boattype }} |
+ {% endif %}
+
+
+ Details
+ |
+ DNF |
+
+ {% endfor %}
{% for result in dns %}
| |
diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py
index 1f6f4a33..9f918437 100644
--- a/rowers/views/racesviews.py
+++ b/rowers/views/racesviews.py
@@ -1072,6 +1072,12 @@ def virtualevent_view(request,id=0):
workoutid__isnull=True,
)
+ dnf = resultobj.objects.filter(
+ race=race,
+ workoutid__isnull=False,
+ coursecompleted=False,
+ )
+
if not request.user.is_anonymous:
if race_can_register(r,race):
@@ -1143,6 +1149,7 @@ def virtualevent_view(request,id=0):
adaptiveclass__in=adaptiveclass,
age__gte=age_min,
age__lte=age_max,
+ coursecompleted=True,
).order_by("duration")
else:
results = resultobj.objects.filter(
@@ -1154,6 +1161,7 @@ def virtualevent_view(request,id=0):
adaptiveclass__in=adaptiveclass,
age__gte=age_min,
age__lte=age_max,
+ coursecompleted=True,
).order_by("duration","-distance")
if entrycategory is not None:
@@ -1179,6 +1187,8 @@ def virtualevent_view(request,id=0):
coursecompleted=True,
).order_by("duration","-distance")
+
+
if results:
form = RaceResultFilterForm(records=records)
else:
@@ -1221,6 +1231,7 @@ def virtualevent_view(request,id=0):
'results':results,
'buttons':buttons,
'dns':dns,
+ 'dnf':dnf,
'records':records,
'racelogo':racelogo,
'form':form,
From d9405b428102402ad1450f47126c8c2cfb8f90d8 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 14:27:24 +0200
Subject: [PATCH 4/9] adding ranking
---
rowers/views/racesviews.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py
index 9f918437..7d2e2dcf 100644
--- a/rowers/views/racesviews.py
+++ b/rowers/views/racesviews.py
@@ -1315,6 +1315,12 @@ def virtualevent_ranking_view(request,id=0):
workoutid__isnull=True,
)
+ dnf = resultobj.objects.filter(
+ race=race,
+ workoutid__isnull=False,
+ coursecompleted=False,
+ )
+
if not request.user.is_anonymous:
if race_can_register(r,race):
From 8b246498dc37671c9dd2fcb71be839ab962513a0 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 16:55:14 +0200
Subject: [PATCH 5/9] changes
---
rowers/tasks.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/rowers/tasks.py b/rowers/tasks.py
index fcd7bc62..7a9a06e4 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -119,7 +119,7 @@ siteurl = SITE_URL
# testing task
from rowers.emails import send_template_email
-from rowers.courseutils import coursetime_paths, coursetime_first, time_in_path
+from rowers.courseutils import coursetime_paths, coursetime_first, time_in_path,InvalidTrajectoryError
@app.task
def add(x, y):
@@ -432,7 +432,11 @@ def handle_check_race_course(self,
paths.append(path)
# check how many times went through start polygon
- entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
+ try:
+ entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
+ except InvalidTrajectoryError:
+ coursecomplete = False
+ return 0
cseconds = []
cmeters = []
From 0ddd39de78c00af2a5d8c3c7b6337ad8a917df8c Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 16:58:13 +0200
Subject: [PATCH 6/9] bug fix
---
rowers/tasks.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rowers/tasks.py b/rowers/tasks.py
index 68a33e89..1f976181 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -544,8 +544,8 @@ def handle_check_race_course(self,
query = 'UPDATE rowers_virtualraceresult SET coursecompleted = 0, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond}, points={points} WHERE id={recordid}'.format(
recordid=recordid,
duration=totaltime_sec_to_string(0),
- distance=0),
- points=0,
+ distance=0,
+ points=0.0,
workoutid=workoutid,
startsecond=startsecond,
endsecond=endsecond,
From 5ad85c077c4db6d2f6f3614b466800cd4b049b00 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 17:10:02 +0200
Subject: [PATCH 7/9] goof
---
rowers/tasks.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/rowers/tasks.py b/rowers/tasks.py
index 1f976181..2a5365fc 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -436,6 +436,9 @@ def handle_check_race_course(self,
path = polygon_to_path(polygon,debug=debug)
paths.append(path)
+ startsecond = 0
+ endsecond = rowdata['time'].max()
+
# check how many times went through start polygon
try:
entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
@@ -570,7 +573,7 @@ def handle_check_race_course(self,
engine.dispose()
# send email
- handle_send_email_coursefail(
+ handle_sendemail_coursefail(
useremail,userfirstname,
)
From 64bb28f75df834c88d10b9d05b01ee6612cfed3a Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 17:21:11 +0200
Subject: [PATCH 8/9] map compare
---
rowers/templates/virtualevent.html | 12 ++++++++++++
rowers/views/workoutviews.py | 1 -
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html
index cd3ffd22..35db46f1 100644
--- a/rowers/templates/virtualevent.html
+++ b/rowers/templates/virtualevent.html
@@ -354,6 +354,11 @@
|
{{ result.username }} |
{{ result.teamname }} |
+ {% if race.coursestandards %}
+ {{ result.entrycategory }} |
+ DNF |
+ DNF |
+ {% else %}
{{ result.age }} |
{{ result.sex }} |
{{ result.weightcategory }} |
@@ -368,6 +373,7 @@
{% if race.sessiontype == 'race' %}
{{ result.boattype }} |
{% endif %}
+ {% endif %}
DNF |
@@ -380,6 +386,11 @@
| |
{{ result.username }} |
{{ result.teamname }} |
+ {% if race.coursestandards %}
+ {{ result.entrycategory }} |
+ DNS |
+ DNS |
+ {% else %}
{{ result.age }} |
{{ result.sex }} |
{{ result.weightcategory }} |
@@ -394,6 +405,7 @@
{% if race.sessiontype == 'race' %}
{{ result.boattype }} |
{% endif %}
+ {% endif %}
DNS |
{% endfor %}
diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py
index a407d0e2..43bea2b4 100644
--- a/rowers/views/workoutviews.py
+++ b/rowers/views/workoutviews.py
@@ -1511,7 +1511,6 @@ def virtualevent_mapcompare_view(request,id=0):
results = VirtualRaceResult.objects.filter(
race=race,
workoutid__isnull=False,
- coursecompleted=True,
).order_by("distance","duration")
workoutids = [result.workoutid for result in results]
From d9753a89fcfbc996a7451433f4ae7d1d83874808 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 12 Jun 2020 17:25:34 +0200
Subject: [PATCH 9/9] adding distance ordering
---
rowers/templates/virtualevent.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html
index 35db46f1..26d16084 100644
--- a/rowers/templates/virtualevent.html
+++ b/rowers/templates/virtualevent.html
@@ -287,7 +287,7 @@
{% endif %}
{% endif %}
Time▼ |
- Distance▼ |
+ Distance▼▲ |
{% if race.coursestandards %}
Points▼ |
{% endif %}