added announcement for hard workout
This commit is contained in:
@@ -654,6 +654,7 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
||||
w.save()
|
||||
|
||||
isbreakthrough = False
|
||||
ishard = False
|
||||
if workouttype == 'water':
|
||||
df = getsmallrowdata_db(['power','workoutid','time'],ids=[w.id])
|
||||
# delta,cpvalues,avgpower = datautils.getsinglecp(row.df)
|
||||
@@ -664,12 +665,15 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
||||
dfgrouped = df.groupby(['workoutid'])
|
||||
delta,cpvalues,avgpower = datautils.getcp(dfgrouped,logarr)
|
||||
|
||||
res,btvalues = utils.isbreakthrough(delta,cpvalues,r.p0,r.p1,r.p2,r.p3,r.cpratio)
|
||||
res,btvalues,res2 = utils.isbreakthrough(delta,cpvalues,r.p0,r.p1,r.p2,r.p3,r.cpratio)
|
||||
else:
|
||||
res = 0
|
||||
res2 = 0
|
||||
if res:
|
||||
isbreakthrough = True
|
||||
res = datautils.updatecp(delta,cpvalues,r)
|
||||
if res2:
|
||||
ishard = True
|
||||
|
||||
# submit email task to send email about breakthrough workout
|
||||
if isbreakthrough:
|
||||
@@ -691,6 +695,26 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
# submit email task to send email about breakthrough workout
|
||||
if ishard:
|
||||
a_messages.info(r.user,'That was a pretty hard workout')
|
||||
if settings.DEBUG and r.getemailnotifications:
|
||||
res = handle_sendemail_hard.delay(w.id,r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json())
|
||||
elif r.getemailnotifications:
|
||||
try:
|
||||
res = queuehigh.enqueue(
|
||||
handle_sendemail_hard(w.id,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json()))
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
|
||||
if privacy == 'visible':
|
||||
ts = Team.objects.filter(rower=r)
|
||||
|
||||
Reference in New Issue
Block a user