diff --git a/rowers/tasks.py b/rowers/tasks.py index 03f7ece1..50277880 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -18,7 +18,8 @@ import matplotlib.pyplot as plt from matplotlib import figure import stravalib - +import pandas as pd + from django_rq import job from utils import serialize_list,deserialize_list @@ -49,7 +50,9 @@ def handle_new_workout_from_file(r,f2, # send email when a breakthrough workout is uploaded @app.task -def handle_sendemail_breakthrough(workoutid,useremail,userfirstname,userlastname): +def handle_sendemail_breakthrough(workoutid,useremail, + userfirstname,userlastname, + btvalues = pd.DataFrame()): # send email with attachment subject = "A breakthrough workout on rowsandall.com" @@ -69,6 +72,18 @@ def handle_sendemail_breakthrough(workoutid,useremail,userfirstname,userlastname message += str(workoutid) message += "/updatecp\n\n" + if not btvalues.empty: + message += "These were the breakthrough values:\n" + for t in btvalues.itertuples(): + delta = t.delta + cpvalue = t.cpvalues + pwr = t.pwr + + message += "Time: "+str(delta)+" seconds\n" + message += "New: "+str(cpvalue)+" Watt\n" + message += "Old: "+str(pwr)+" Watt\n\n" + + message += "To opt out of these email notifications, deselect the checkbox on your Profile page under Account Information.\n\n" message += "Best Regards, the Rowsandall Team" @@ -222,10 +237,11 @@ def handle_otwsetpower(f1,boattype,weightvalue, update_strokedata(workoutid,rowdata.df,debug=debug) delta,cpvalues,avgpower = datautils.getsinglecp(rowdata.df) - if utils.isbreakthrough(delta,cpvalues,ps[0],ps[1],ps[2],ps[3],ratio): + res,deltas = utils.isbreakthrough(delta,cpvalues,ps[0],ps[1],ps[2],ps[3],ratio) + if res: handle_sendemail_breakthrough(workoutid,email, first_name, - last_name) + last_name,deltas) # send email fullemail = first_name + " " + last_name + " " + "<" + email + ">" diff --git a/rowers/templates/streamedit.html b/rowers/templates/streamedit.html index 56079e4d..1e4ba1a0 100644 --- a/rowers/templates/streamedit.html +++ b/rowers/templates/streamedit.html @@ -7,49 +7,57 @@ {% block content %}
- -

Stream Editor

-
-

- Edit Workout -

-
-
-

- Advanced Edit -

- -
-
-

OTW Power

- Run calculations to get power values for your row. - -
-
-

- Edit river Stream between turning points in your row. - Use positive (+) values to denote rowing with the stream, - negative (-) values to denote rowing against the stream. -

- +
+

Stream Editor

+
+
+
+

+ Edit Workout +

+
+
+

+ Advanced Edit +

+ +
+
+

OTW Power

+ Run calculations to get power values for your row. + +
+
+
+
+

Wind Edit

+
+
+
+

+ Edit river Stream between turning points in your row. + Use positive (+) values to denote rowing with the stream, + negative (-) values to denote rowing against the stream. +

+
- {% if form.errors %} -

- Please correct the error{{ form.errors|pluralize }} below. -

- {% endif %} - - - {{ form.as_table }} -
- {% csrf_token %} -
-
- -
- - - + {% if form.errors %} +

+ Please correct the error{{ form.errors|pluralize }} below. +

+ {% endif %} + + + {{ form.as_table }} +
+ {% csrf_token %} +
+
+ +
+ + +
@@ -86,4 +94,4 @@ {{ the_div |safe }}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/rowers/templates/windedit.html b/rowers/templates/windedit.html index 0d98cce7..79d9ce7d 100644 --- a/rowers/templates/windedit.html +++ b/rowers/templates/windedit.html @@ -6,113 +6,121 @@ {% block content %}
- -

Wind Editor

-
-

- Edit Workout -

-
-
-

- Advanced Edit -

- -
-
-

OTW Power

- Run calculations to get power values for your row. - -
-
-

- Update wind between distance 1 and distance 2. Submit wind strength - and direction at start and end of segment. Blank the form for values - you want to keep intact. -

- -

- Check www.wunderground.com - to find historical weather data from an on-line weather station near - the location of your row. -

- -
-
- {% if form.errors %} +
+

Wind Editor

+
+
+
+

+ Edit Workout +

+
+
+

+ Advanced Edit +

+ +
+
+

OTW Power

+ Run calculations to get power values for your row. + +
+
+
+ +
+
+

+ Update wind between distance 1 and distance 2. Submit wind strength + and direction at start and end of segment. Blank the form for values + you want to keep intact. +

+ +

+ Check www.wunderground.com + to find historical weather data from an on-line weather station near + the location of your row. +

+ +
+ + {% if form.errors %}

- Please correct the error{{ form.errors|pluralize }} below. + Please correct the error{{ form.errors|pluralize }} below.

- {% endif %} + {% endif %} - {{ form.as_table }} + {{ form.as_table }}
{% csrf_token %} - -
-
-

Closest Airport Weather: {{ airport }} - ({{ airportdistance | floatformat:-1 }} km) - Airport Data

-

+ +

+
+

Closest Airport Weather: {{ airport }} + ({{ airportdistance | floatformat:-1 }} km) + Airport Data

+

Dark Sky Data -

+

Download wind speed and bearing from The Dark Sky -

-
-
- -

+

+
+
+ +

Manual update of the wind data from the form. -

-
- - -
+

+
+ + +
- - - + - - {{ interactiveplot |safe }} - - {{ gmap |safe }} - - + + {{ interactiveplot |safe }} + + {{ gmap |safe }} + + - - - -
-
- {{ the_div |safe }} -
-
- -
-
- {{ gmapdiv |safe }} -
-
- + + + +
+
+ {{ the_div |safe }} +
+
+ +
+
+ {{ gmapdiv |safe }} +
+
+ {% endblock %} diff --git a/rowers/utils.py b/rowers/utils.py index 3fd67d94..5036dac2 100644 --- a/rowers/utils.py +++ b/rowers/utils.py @@ -1,6 +1,6 @@ import math import numpy as np - +import pandas as pd lbstoN = 4.44822 @@ -85,4 +85,11 @@ def isbreakthrough(delta,cpvalues,p0,p1,p2,p3,ratio): res = np.sum(cpvalues>pwr) - return res>1 + btdf = pd.DataFrame( + { + 'delta':delta[cpvalues>pwr], + 'cpvalues':cpvalues[cpvalues>pwr], + 'pwr':pwr[cpvalues>pwr], + } + ) + return res>1,btdf diff --git a/rowers/views.py b/rowers/views.py index f336270d..e61d7822 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -4403,8 +4403,9 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""): rowdata.write_csv(f1,gzip=True) # do power calculation (asynchronous) - u = request.user - r = Rower.objects.get(user=u) + r = row.user + u = r.user + first_name = u.first_name last_name = u.last_name emailaddress = u.email diff --git a/rowsanda_107501 b/rowsanda_107501 index a01511d5..f2be9658 100644 Binary files a/rowsanda_107501 and b/rowsanda_107501 differ