refactoring and adding email confirmation / trimp calc to api v2
This commit is contained in:
@@ -1430,6 +1430,53 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
|
||||
|
||||
from rowers.utils import totaltime_sec_to_string
|
||||
|
||||
def checkbreakthrough(w, r):
|
||||
isbreakthrough = False
|
||||
ishard = False
|
||||
workouttype = w.workouttype
|
||||
if workouttype in rowtypes:
|
||||
cpdf,delta,cpvalues = setcp(w)
|
||||
if not cpdf.empty:
|
||||
if workouttype in otwtypes:
|
||||
res, btvalues, res2 = utils.isbreakthrough(
|
||||
delta, cpvalues, r.p0, r.p1, r.p2, r.p3, r.cpratio)
|
||||
success = update_rolling_cp(r,otwtypes,'water')
|
||||
|
||||
elif workouttype in otetypes:
|
||||
res, btvalues, res2 = utils.isbreakthrough(
|
||||
delta, cpvalues, r.ep0, r.ep1, r.ep2, r.ep3, r.ecpratio)
|
||||
success = update_rolling_cp(r,otetypes,'erg')
|
||||
else:
|
||||
res = 0
|
||||
res2 = 0
|
||||
if res:
|
||||
isbreakthrough = True
|
||||
if res2 and not isbreakthrough:
|
||||
ishard = True
|
||||
|
||||
# submit email task to send email about breakthrough workout
|
||||
if isbreakthrough:
|
||||
if r.getemailnotifications and not r.emailbounced:
|
||||
job = myqueue(queuehigh,handle_sendemail_breakthrough,
|
||||
w.id,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json())
|
||||
|
||||
# submit email task to send email about breakthrough workout
|
||||
if ishard:
|
||||
if r.getemailnotifications and not r.emailbounced:
|
||||
job = myqueue(queuehigh,handle_sendemail_hard,
|
||||
w.id,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json())
|
||||
|
||||
return isbreakthrough, ishard
|
||||
|
||||
|
||||
# Processes painsled CSV file to database
|
||||
def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
boattype='1x',
|
||||
@@ -1701,48 +1748,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
|
||||
job = myqueue(queuehigh,handle_calctrimp,w.id,f2,r.ftp,r.sex,r.hrftp,r.max,r.rest)
|
||||
|
||||
|
||||
isbreakthrough = False
|
||||
ishard = False
|
||||
if workouttype in rowtypes:
|
||||
cpdf,delta,cpvalues = setcp(w)
|
||||
if not cpdf.empty:
|
||||
if workouttype in otwtypes:
|
||||
res, btvalues, res2 = utils.isbreakthrough(
|
||||
delta, cpvalues, r.p0, r.p1, r.p2, r.p3, r.cpratio)
|
||||
success = update_rolling_cp(r,otwtypes,'water')
|
||||
|
||||
elif workouttype in otetypes:
|
||||
res, btvalues, res2 = utils.isbreakthrough(
|
||||
delta, cpvalues, r.ep0, r.ep1, r.ep2, r.ep3, r.ecpratio)
|
||||
success = update_rolling_cp(r,otetypes,'erg')
|
||||
else:
|
||||
res = 0
|
||||
res2 = 0
|
||||
if res:
|
||||
isbreakthrough = True
|
||||
if res2 and not isbreakthrough:
|
||||
ishard = True
|
||||
|
||||
# submit email task to send email about breakthrough workout
|
||||
if isbreakthrough:
|
||||
if r.getemailnotifications and not r.emailbounced:
|
||||
job = myqueue(queuehigh,handle_sendemail_breakthrough,
|
||||
w.id,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json())
|
||||
|
||||
# submit email task to send email about breakthrough workout
|
||||
if ishard:
|
||||
if r.getemailnotifications and not r.emailbounced:
|
||||
job = myqueue(queuehigh,handle_sendemail_hard,
|
||||
w.id,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json())
|
||||
isbreakthrough, ishard = checkbreakthrough(w, r)
|
||||
|
||||
return (w.id, message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user