added delta values to breakthrough email
This commit is contained in:
@@ -18,7 +18,8 @@ import matplotlib.pyplot as plt
|
|||||||
from matplotlib import figure
|
from matplotlib import figure
|
||||||
|
|
||||||
import stravalib
|
import stravalib
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
from django_rq import job
|
from django_rq import job
|
||||||
|
|
||||||
from utils import serialize_list,deserialize_list
|
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
|
# send email when a breakthrough workout is uploaded
|
||||||
@app.task
|
@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
|
# send email with attachment
|
||||||
subject = "A breakthrough workout on rowsandall.com"
|
subject = "A breakthrough workout on rowsandall.com"
|
||||||
@@ -69,6 +72,18 @@ def handle_sendemail_breakthrough(workoutid,useremail,userfirstname,userlastname
|
|||||||
message += str(workoutid)
|
message += str(workoutid)
|
||||||
message += "/updatecp\n\n"
|
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 += "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"
|
message += "Best Regards, the Rowsandall Team"
|
||||||
@@ -222,10 +237,11 @@ def handle_otwsetpower(f1,boattype,weightvalue,
|
|||||||
update_strokedata(workoutid,rowdata.df,debug=debug)
|
update_strokedata(workoutid,rowdata.df,debug=debug)
|
||||||
|
|
||||||
delta,cpvalues,avgpower = datautils.getsinglecp(rowdata.df)
|
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,
|
handle_sendemail_breakthrough(workoutid,email,
|
||||||
first_name,
|
first_name,
|
||||||
last_name)
|
last_name,deltas)
|
||||||
|
|
||||||
# send email
|
# send email
|
||||||
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
||||||
|
|||||||
@@ -7,49 +7,57 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="workouts" class="grid_6 alpha">
|
<div id="workouts" class="grid_6 alpha">
|
||||||
|
|
||||||
|
<div class="grid_6 alpha">
|
||||||
<h1>Stream Editor</h1>
|
<h1>Stream Editor</h1>
|
||||||
<div class="grid_2 alpha">
|
</div>
|
||||||
<p>
|
<div class="grid_6 alpha">
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
<div class="grid_2 alpha">
|
||||||
</p>
|
<p>
|
||||||
</div>
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||||
<div class="grid_2">
|
</p>
|
||||||
<p>
|
</div>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
<div class="grid_2">
|
||||||
</p>
|
<p>
|
||||||
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||||
</div>
|
</p>
|
||||||
<div class="grid_2 omega tooltip">
|
|
||||||
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
</div>
|
||||||
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
<div class="grid_2 omega tooltip">
|
||||||
|
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
||||||
</div>
|
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<p>
|
</div>
|
||||||
Edit river Stream between turning points in your row.
|
</div>
|
||||||
Use positive (+) values to denote rowing with the stream,
|
<div class="grid_6 alpha">
|
||||||
negative (-) values to denote rowing against the stream.
|
<div class="grid_2 prefix_4 alpha">
|
||||||
</p>
|
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/wind">Wind Edit</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid_6 alpha">
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
|
||||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||||
{% if form.errors %}
|
{% if form.errors %}
|
||||||
<p style="color: red;">
|
<p style="color: red;">
|
||||||
Please correct the error{{ form.errors|pluralize }} below.
|
Please correct the error{{ form.errors|pluralize }} below.
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
</div>
|
</div>
|
||||||
<div id="formbutton" class="grid_1 prefix_3 suffix_2">
|
<div id="formbutton" class="grid_1 prefix_3 suffix_2">
|
||||||
<input class="button green" type="submit" value="Update">
|
<input class="button green" type="submit" value="Update">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<img src="/static/img/rivercurrent.jpg" width="400">
|
<img src="/static/img/rivercurrent.jpg" width="400">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="advancedplots" class="grid_6 omega">
|
<div id="advancedplots" class="grid_6 omega">
|
||||||
@@ -86,4 +94,4 @@
|
|||||||
{{ the_div |safe }}
|
{{ the_div |safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -6,113 +6,121 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="workouts" class="grid_6 alpha">
|
<div id="workouts" class="grid_6 alpha">
|
||||||
|
<div class="grid_6 alpha">
|
||||||
<h1>Wind Editor</h1>
|
<h1>Wind Editor</h1>
|
||||||
<div class="grid_2 alpha">
|
</div>
|
||||||
<p>
|
<div class="grid_6 alpha">
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
<div class="grid_2 alpha">
|
||||||
</p>
|
<p>
|
||||||
</div>
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||||
<div class="grid_2">
|
</p>
|
||||||
<p>
|
</div>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
<div class="grid_2">
|
||||||
</p>
|
<p>
|
||||||
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||||
</div>
|
</p>
|
||||||
<div class="grid_2 omega tooltip">
|
|
||||||
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
</div>
|
||||||
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
<div class="grid_2 omega tooltip">
|
||||||
|
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
||||||
</div>
|
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<p>
|
</div>
|
||||||
Update wind between distance 1 and distance 2. Submit wind strength
|
</div>
|
||||||
and direction at start and end of segment. Blank the form for values
|
<div class="grid_6 alpha">
|
||||||
you want to keep intact.
|
<div class="grid_2 prefix_4 alpha">
|
||||||
</p>
|
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/stream">Stream Edit</a></p>
|
||||||
|
</div>
|
||||||
<p>
|
</div>
|
||||||
Check <a href="https://www.wunderground.com">www.wunderground.com</a>
|
<div class="grid_6 alpha">
|
||||||
to find historical weather data from an on-line weather station near
|
<p>
|
||||||
the location of your row.
|
Update wind between distance 1 and distance 2. Submit wind strength
|
||||||
</p>
|
and direction at start and end of segment. Blank the form for values
|
||||||
|
you want to keep intact.
|
||||||
<div class="grid_4 alpha">
|
</p>
|
||||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
|
||||||
{% if form.errors %}
|
<p>
|
||||||
|
Check <a href="https://www.wunderground.com">www.wunderground.com</a>
|
||||||
|
to find historical weather data from an on-line weather station near
|
||||||
|
the location of your row.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="grid_4 alpha">
|
||||||
|
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||||
|
{% if form.errors %}
|
||||||
<p style="color: red;">
|
<p style="color: red;">
|
||||||
Please correct the error{{ form.errors|pluralize }} below.
|
Please correct the error{{ form.errors|pluralize }} below.
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 omega">
|
<div class="grid_2 omega">
|
||||||
<p>Closest Airport Weather: {{ airport }}
|
<p>Closest Airport Weather: {{ airport }}
|
||||||
({{ airportdistance | floatformat:-1 }} km)
|
({{ airportdistance | floatformat:-1 }} km)
|
||||||
<a class="button green small" href="/rowers/workout/{{ workout.id }}/metar/{{ airport }}">Airport Data</a></p>
|
<a class="button green small" href="/rowers/workout/{{ workout.id }}/metar/{{ airport }}">Airport Data</a></p>
|
||||||
<p>
|
<p>
|
||||||
<a class="button green small" href="/rowers/workout/{{ workout.id }}/darkskywind">Dark Sky Data</a>
|
<a class="button green small" href="/rowers/workout/{{ workout.id }}/darkskywind">Dark Sky Data</a>
|
||||||
<p>
|
<p>
|
||||||
Download wind speed and bearing from <a href="http://forecast.io/">The Dark Sky</a>
|
Download wind speed and bearing from <a href="http://forecast.io/">The Dark Sky</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 omega">
|
<div class="grid_2 omega">
|
||||||
<input class="button green small" type="submit" value="Submit Form">
|
<input class="button green small" type="submit" value="Submit Form">
|
||||||
<p>
|
<p>
|
||||||
Manual update of the wind data from the form.
|
Manual update of the wind data from the form.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<img src="http://cliparts.co/cliparts/rTn/KaR/rTnKaRrxc.gif" width="400">
|
<img src="http://cliparts.co/cliparts/rTn/KaR/rTnKaRrxc.gif" width="400">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="advancedplots" class="grid_6 omega">
|
<div id="advancedplots" class="grid_6 omega">
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
<script async="true" type="text/javascript">
|
||||||
Bokeh.set_log_level("info");
|
Bokeh.set_log_level("info");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{ interactiveplot |safe }}
|
{{ interactiveplot |safe }}
|
||||||
|
|
||||||
{{ gmap |safe }}
|
{{ gmap |safe }}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Set things up to resize the plot on a window resize. You can play with
|
// Set things up to resize the plot on a window resize. You can play with
|
||||||
// the arguments of resize_width_height() to change the plot's behavior.
|
// the arguments of resize_width_height() to change the plot's behavior.
|
||||||
var plot_resize_setup = function () {
|
var plot_resize_setup = function () {
|
||||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||||
var plot = Bokeh.index[plotid];
|
var plot = Bokeh.index[plotid];
|
||||||
var plotresizer = function() {
|
var plotresizer = function() {
|
||||||
// arguments: use width, use height, maintain aspect ratio
|
// arguments: use width, use height, maintain aspect ratio
|
||||||
plot.resize_width_height(true, true, true);
|
plot.resize_width_height(true, true, true);
|
||||||
};
|
};
|
||||||
window.addEventListener('resize', plotresizer);
|
window.addEventListener('resize', plotresizer);
|
||||||
plotresizer();
|
plotresizer();
|
||||||
};
|
};
|
||||||
window.addEventListener('load', plot_resize_setup);
|
window.addEventListener('load', plot_resize_setup);
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||||
html, body {height: 100%; margin:5px;}
|
html, body {height: 100%; margin:5px;}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<div id="interactiveplot" class="grid_6 omega">
|
<div id="interactiveplot" class="grid_6 omega">
|
||||||
<div class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
{{ the_div |safe }}
|
{{ the_div |safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="interactiveplot" class="grid_6 omega">
|
<div id="interactiveplot" class="grid_6 omega">
|
||||||
<div class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
{{ gmapdiv |safe }}
|
{{ gmapdiv |safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import math
|
import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
lbstoN = 4.44822
|
lbstoN = 4.44822
|
||||||
|
|
||||||
@@ -85,4 +85,11 @@ def isbreakthrough(delta,cpvalues,p0,p1,p2,p3,ratio):
|
|||||||
|
|
||||||
res = np.sum(cpvalues>pwr)
|
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
|
||||||
|
|||||||
@@ -4403,8 +4403,9 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
|
|||||||
rowdata.write_csv(f1,gzip=True)
|
rowdata.write_csv(f1,gzip=True)
|
||||||
|
|
||||||
# do power calculation (asynchronous)
|
# do power calculation (asynchronous)
|
||||||
u = request.user
|
r = row.user
|
||||||
r = Rower.objects.get(user=u)
|
u = r.user
|
||||||
|
|
||||||
first_name = u.first_name
|
first_name = u.first_name
|
||||||
last_name = u.last_name
|
last_name = u.last_name
|
||||||
emailaddress = u.email
|
emailaddress = u.email
|
||||||
|
|||||||
BIN
rowsanda_107501
BIN
rowsanda_107501
Binary file not shown.
Reference in New Issue
Block a user