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 + ">"
|
||||
|
||||
Reference in New Issue
Block a user