added delta values to breakthrough email
This commit is contained in:
@@ -18,6 +18,7 @@ import matplotlib.pyplot as plt
|
||||
from matplotlib import figure
|
||||
|
||||
import stravalib
|
||||
import pandas as pd
|
||||
|
||||
from django_rq import job
|
||||
|
||||
@@ -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,8 +7,10 @@
|
||||
{% block content %}
|
||||
<div id="workouts" class="grid_6 alpha">
|
||||
|
||||
|
||||
<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>
|
||||
@@ -25,6 +27,12 @@
|
||||
<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.
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
|
||||
{% block content %}
|
||||
<div id="workouts" class="grid_6 alpha">
|
||||
|
||||
<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>
|
||||
@@ -24,6 +26,12 @@
|
||||
<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
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
rowsanda_107501
BIN
rowsanda_107501
Binary file not shown.
Reference in New Issue
Block a user