Offline CP calculations for OTW
A new table in the database with precalculated CP values. The data are updated through RQ/Celery asynchronous functions
This commit is contained in:
@@ -26,7 +26,7 @@ from utils import deserialize_list
|
||||
|
||||
from rowers.dataprepnodjango import (
|
||||
update_strokedata, new_workout_from_file,
|
||||
getsmallrowdata_db,
|
||||
getsmallrowdata_db, updatecpdata_sql
|
||||
)
|
||||
|
||||
from django.core.mail import send_mail, EmailMessage
|
||||
@@ -402,7 +402,26 @@ def handle_otwsetpower(f1, boattype, weightvalue,
|
||||
|
||||
# This function generates all the static (PNG image) plots
|
||||
|
||||
@app.task
|
||||
def handle_updatecp(rower_id,workoutids,debug=False):
|
||||
columns = ['power','workoutid','time']
|
||||
df = getsmallrowdata_db(columns,ids=workoutids,debug=debug)
|
||||
dfgrouped = df.groupby(['workoutid'])
|
||||
|
||||
if not df.empty:
|
||||
maxt = 1.05*df['time'].max()/1000.
|
||||
else:
|
||||
maxt = 1000.
|
||||
|
||||
logarr = datautils.getlogarr(maxt)
|
||||
|
||||
|
||||
delta,cpvalue,avgpower = datautils.getcp(dfgrouped,logarr)
|
||||
|
||||
updatecpdata_sql(rower_id,delta,cpvalue,debug=debug)
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user