added delta values to breakthrough email
This commit is contained in:
@@ -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 + ">"
|
||||
|
||||
@@ -7,49 +7,57 @@
|
||||
{% block content %}
|
||||
<div id="workouts" class="grid_6 alpha">
|
||||
|
||||
|
||||
<h1>Stream Editor</h1>
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="grid_2 omega tooltip">
|
||||
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
||||
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
||||
|
||||
</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>
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<h1>Stream Editor</h1>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="grid_2 omega tooltip">
|
||||
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
||||
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 prefix_4 alpha">
|
||||
<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">
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
</div>
|
||||
<div id="formbutton" class="grid_1 prefix_3 suffix_2">
|
||||
<input class="button green" type="submit" value="Update">
|
||||
</div>
|
||||
</form>
|
||||
<img src="/static/img/rivercurrent.jpg" width="400">
|
||||
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
</div>
|
||||
<div id="formbutton" class="grid_1 prefix_3 suffix_2">
|
||||
<input class="button green" type="submit" value="Update">
|
||||
</div>
|
||||
</form>
|
||||
<img src="/static/img/rivercurrent.jpg" width="400">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="advancedplots" class="grid_6 omega">
|
||||
@@ -86,4 +94,4 @@
|
||||
{{ the_div |safe }}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -6,113 +6,121 @@
|
||||
|
||||
{% block content %}
|
||||
<div id="workouts" class="grid_6 alpha">
|
||||
|
||||
<h1>Wind Editor</h1>
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="grid_2 omega tooltip">
|
||||
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
||||
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
||||
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
|
||||
<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 %}
|
||||
<div class="grid_6 alpha">
|
||||
<h1>Wind Editor</h1>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="grid_2 omega tooltip">
|
||||
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
|
||||
<span class="tooltiptext">Run calculations to get power values for your row.</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 prefix_4 alpha">
|
||||
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/stream">Stream Edit</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
|
||||
<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;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>Closest Airport Weather: {{ airport }}
|
||||
({{ airportdistance | floatformat:-1 }} km)
|
||||
<a class="button green small" href="/rowers/workout/{{ workout.id }}/metar/{{ airport }}">Airport Data</a></p>
|
||||
<p>
|
||||
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>Closest Airport Weather: {{ airport }}
|
||||
({{ airportdistance | floatformat:-1 }} km)
|
||||
<a class="button green small" href="/rowers/workout/{{ workout.id }}/metar/{{ airport }}">Airport Data</a></p>
|
||||
<p>
|
||||
<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>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<input class="button green small" type="submit" value="Submit Form">
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<input class="button green small" type="submit" value="Submit Form">
|
||||
<p>
|
||||
Manual update of the wind data from the form.
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<img src="http://cliparts.co/cliparts/rTn/KaR/rTnKaRrxc.gif" width="400">
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<img src="http://cliparts.co/cliparts/rTn/KaR/rTnKaRrxc.gif" width="400">
|
||||
</div>
|
||||
</div>
|
||||
<div id="advancedplots" class="grid_6 omega">
|
||||
|
||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||
<script async="true" type="text/javascript">
|
||||
|
||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||
<script async="true" type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
|
||||
{{ gmap |safe }}
|
||||
|
||||
<script>
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
|
||||
{{ gmap |safe }}
|
||||
|
||||
<script>
|
||||
// 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.
|
||||
var plot_resize_setup = function () {
|
||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||
var plot = Bokeh.index[plotid];
|
||||
var plotresizer = function() {
|
||||
// arguments: use width, use height, maintain aspect ratio
|
||||
plot.resize_width_height(true, true, true);
|
||||
};
|
||||
window.addEventListener('resize', plotresizer);
|
||||
plotresizer();
|
||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||
var plot = Bokeh.index[plotid];
|
||||
var plotresizer = function() {
|
||||
// arguments: use width, use height, maintain aspect ratio
|
||||
plot.resize_width_height(true, true, true);
|
||||
};
|
||||
window.addEventListener('resize', plotresizer);
|
||||
plotresizer();
|
||||
};
|
||||
window.addEventListener('load', plot_resize_setup);
|
||||
</script>
|
||||
<style>
|
||||
</script>
|
||||
<style>
|
||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||
html, body {height: 100%; margin:5px;}
|
||||
</style>
|
||||
|
||||
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
<div class="grid_6 alpha">
|
||||
{{ the_div |safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
<div class="grid_6 alpha">
|
||||
{{ gmapdiv |safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
<div class="grid_6 alpha">
|
||||
{{ the_div |safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
<div class="grid_6 alpha">
|
||||
{{ gmapdiv |safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user