Private
Public Access
1
0

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:
Sander Roosendaal
2017-10-25 15:17:14 +02:00
parent 470e809ebf
commit 74acd35e7a
6 changed files with 194 additions and 35 deletions

View File

@@ -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):