refactoring and adding email confirmation / trimp calc to api v2
This commit is contained in:
22
apilog.log
Normal file
22
apilog.log
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
2020-12-31 05:38:33.044672+00:00: sander (strokedatajson_v2 POST)
|
||||||
|
No data in request
|
||||||
|
1595667900.0: sander(strokedatajson_v2 POST - data parsed)
|
||||||
|
2020-12-31 05:39:20.796493+00:00: sander (strokedatajson_v2 POST)
|
||||||
|
No data in request
|
||||||
|
2020-12-31 05:39:35.245274+00:00: sander (strokedatajson_v2 POST)
|
||||||
|
No data in request
|
||||||
|
1595667900.0: sander(strokedatajson_v2 POST - data parsed)
|
||||||
|
2020-12-31 05:40:51.057825+00:00: sander (strokedatajson_v2 POST)
|
||||||
|
No data in request
|
||||||
|
1595667900.0: sander(strokedatajson_v2 POST - data parsed)
|
||||||
|
2020-12-31 05:40:52.842430+00:00: sander (strokedatajson_v2 POST completed successfully)
|
||||||
|
2020-12-31 05:50:10.246269+00:00: sander (strokedatajson_v2 POST)
|
||||||
|
No data in request
|
||||||
|
1595667900.0: sander(strokedatajson_v2 POST - data parsed)
|
||||||
|
2020-12-31 05:50:54.083948+00:00: sander (strokedatajson_v2 POST)
|
||||||
|
No data in request
|
||||||
|
1595667900.0: sander(strokedatajson_v2 POST - data parsed)
|
||||||
|
2020-12-31 05:51:50.273905+00:00: sander (strokedatajson_v2 POST)
|
||||||
|
No data in request
|
||||||
|
1595667900.0: sander(strokedatajson_v2 POST - data parsed)
|
||||||
|
2020-12-31 05:51:52.185284+00:00: sander (strokedatajson_v2 POST completed successfully)
|
||||||
@@ -1430,6 +1430,53 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
|
|||||||
|
|
||||||
from rowers.utils import totaltime_sec_to_string
|
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
|
# Processes painsled CSV file to database
|
||||||
def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||||
boattype='1x',
|
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)
|
job = myqueue(queuehigh,handle_calctrimp,w.id,f2,r.ftp,r.sex,r.hrftp,r.max,r.rest)
|
||||||
|
|
||||||
|
isbreakthrough, ishard = checkbreakthrough(w, r)
|
||||||
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())
|
|
||||||
|
|
||||||
return (w.id, message)
|
return (w.id, message)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ from __future__ import print_function
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from rowers.views.statements import *
|
from rowers.views.statements import *
|
||||||
|
from rowers.tasks import handle_calctrimp
|
||||||
|
from rowers.mailprocessing import send_confirm
|
||||||
|
|
||||||
# Stroke data form to test API upload
|
# Stroke data form to test API upload
|
||||||
@login_required()
|
@login_required()
|
||||||
@@ -310,6 +311,22 @@ def strokedatajson_v2(request,id):
|
|||||||
|
|
||||||
datadf = dataprep.dataprep(rowdata,id=row.id,bands=True,barchart=True,otwpower=True,empower=True)
|
datadf = dataprep.dataprep(rowdata,id=row.id,bands=True,barchart=True,otwpower=True,empower=True)
|
||||||
|
|
||||||
|
job = myqueue(queuehigh, handle_calctrimp, row.id, row.csvfilename, r.ftp,r.sex,r.hrftp, r.max, r.rest)
|
||||||
|
|
||||||
|
isbreakthrough, ishard = dataprep.checkbreakthrough(row, r)
|
||||||
|
|
||||||
|
if r.getemailnotifications and not r.emailbounced:
|
||||||
|
link = settings.SITE_URL+reverse(
|
||||||
|
r.defaultlandingpage,
|
||||||
|
kwargs = {
|
||||||
|
'id':encoder.encode_hex(row.id),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
email_sent = send_confirm(r.user, row.name, link, '')
|
||||||
|
|
||||||
|
result = uploads.do_sync(row,{},quick=True)
|
||||||
|
|
||||||
|
|
||||||
with open('apilog.log','a') as logfile:
|
with open('apilog.log','a') as logfile:
|
||||||
logfile.write(str(timezone.now())+": ")
|
logfile.write(str(timezone.now())+": ")
|
||||||
logfile.write(request.user.username+" (strokedatajson_v2 POST completed successfully) \n")
|
logfile.write(request.user.username+" (strokedatajson_v2 POST completed successfully) \n")
|
||||||
|
|||||||
Reference in New Issue
Block a user