offline background cp chart creation
This commit is contained in:
@@ -23,7 +23,7 @@ from rowingdata import (
|
|||||||
get_file_type, get_empower_rigging,get_empower_firmware
|
get_file_type, get_empower_rigging,get_empower_firmware
|
||||||
)
|
)
|
||||||
|
|
||||||
from rowers.tasks import handle_sendemail_unrecognized
|
from rowers.tasks import handle_sendemail_unrecognized,handle_setcp
|
||||||
from rowers.tasks import handle_zip_file
|
from rowers.tasks import handle_zip_file
|
||||||
|
|
||||||
from pandas import DataFrame, Series
|
from pandas import DataFrame, Series
|
||||||
@@ -1044,8 +1044,14 @@ def fetchcp_new(rower,workouts):
|
|||||||
|
|
||||||
return df['delta'],df['cp'],0,df['workout']
|
return df['delta'],df['cp'],0,df['workout']
|
||||||
|
|
||||||
def setcp(workout):
|
def setcp(workout,background=False):
|
||||||
|
filename = 'media/cpdata_{id}.parquet.gz'.format(id=workout.id)
|
||||||
|
|
||||||
strokesdf = getsmallrowdata_db(['power','workoutid','time'],ids = [workout.id])
|
strokesdf = getsmallrowdata_db(['power','workoutid','time'],ids = [workout.id])
|
||||||
|
if background:
|
||||||
|
job = myqueue(queuelow,handle_setcp,strokesdf,filename,workout.id)
|
||||||
|
return job.id
|
||||||
|
|
||||||
if not strokesdf.empty:
|
if not strokesdf.empty:
|
||||||
totaltime = strokesdf['time'].max()
|
totaltime = strokesdf['time'].max()
|
||||||
try:
|
try:
|
||||||
@@ -1061,7 +1067,7 @@ def setcp(workout):
|
|||||||
logarr = datautils.getlogarr(maxt)
|
logarr = datautils.getlogarr(maxt)
|
||||||
dfgrouped = strokesdf.groupby(['workoutid'])
|
dfgrouped = strokesdf.groupby(['workoutid'])
|
||||||
delta, cpvalues, avgpower = datautils.getcp(dfgrouped, logarr)
|
delta, cpvalues, avgpower = datautils.getcp(dfgrouped, logarr)
|
||||||
filename = 'media/cpdata_{id}.parquet.gz'.format(id=workout.id)
|
|
||||||
df = pd.DataFrame({
|
df = pd.DataFrame({
|
||||||
'delta':delta,
|
'delta':delta,
|
||||||
'cp':cpvalues,
|
'cp':cpvalues,
|
||||||
|
|||||||
@@ -2704,6 +2704,38 @@ def handle_sendemail_invite_reject(email, name, teamname, managername,
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@app.task
|
||||||
|
def handle_setcp(strokesdf,filename,workoutid,debug=False,**kwargs):
|
||||||
|
try:
|
||||||
|
os.remove(filename)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
if not strokesdf.empty:
|
||||||
|
totaltime = strokesdf['time'].max()
|
||||||
|
try:
|
||||||
|
powermean = strokesdf['power'].mean()
|
||||||
|
except KeyError:
|
||||||
|
powermean = 0
|
||||||
|
|
||||||
|
if powermean != 0:
|
||||||
|
thesecs = totaltime
|
||||||
|
maxt = 1.05 * thesecs
|
||||||
|
|
||||||
|
if maxt > 0:
|
||||||
|
logarr = datautils.getlogarr(maxt)
|
||||||
|
dfgrouped = strokesdf.groupby(['workoutid'])
|
||||||
|
delta, cpvalues, avgpower = datautils.getcp(dfgrouped, logarr)
|
||||||
|
|
||||||
|
df = pd.DataFrame({
|
||||||
|
'delta':delta,
|
||||||
|
'cp':cpvalues,
|
||||||
|
'id':workoutid,
|
||||||
|
})
|
||||||
|
df.to_parquet(filename,engine='fastparquet',compression='GZIP')
|
||||||
|
return 1
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def handle_sendemail_invite_accept(email, name, teamname, managername,
|
def handle_sendemail_invite_accept(email, name, teamname, managername,
|
||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
|
|||||||
@@ -5035,6 +5035,7 @@ def history_view_data(request,userid=0):
|
|||||||
ddict['hrmax'] = ddf['hr'].max().astype(int)
|
ddict['hrmax'] = ddf['hr'].max().astype(int)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
ddict['hrmax'] = 0
|
ddict['hrmax'] = 0
|
||||||
|
|
||||||
ddict['powermean'] = int(wavg(df,'power','deltat'))
|
ddict['powermean'] = int(wavg(df,'power','deltat'))
|
||||||
ddict['powermax'] = ddf['power'].max().astype(int)
|
ddict['powermax'] = ddf['power'].max().astype(int)
|
||||||
ddict['nrworkouts'] = a_workouts.count()
|
ddict['nrworkouts'] = a_workouts.count()
|
||||||
|
|||||||
Reference in New Issue
Block a user