working, not tested asynchronous OTE ranking
This commit is contained in:
@@ -26,7 +26,7 @@ from rowingdata import (
|
||||
MysteryParser, BoatCoachOTWParser,
|
||||
painsledDesktopParser, speedcoachParser, ErgStickParser,
|
||||
SpeedCoach2Parser, FITParser, fitsummarydata,
|
||||
make_cumvalues,
|
||||
make_cumvalues,cumcpdata,
|
||||
summarydata, get_file_type,
|
||||
)
|
||||
|
||||
@@ -41,7 +41,7 @@ import itertools
|
||||
import math
|
||||
from tasks import (
|
||||
handle_sendemail_unrecognized, handle_sendemail_breakthrough,
|
||||
handle_sendemail_hard, handle_updatecp
|
||||
handle_sendemail_hard, handle_updatecp,handle_updateergcp
|
||||
)
|
||||
|
||||
from django.conf import settings
|
||||
@@ -426,20 +426,22 @@ def paceformatsecs(values):
|
||||
|
||||
return out
|
||||
|
||||
def getcpdata_sql(rower_id):
|
||||
def getcpdata_sql(rower_id,table='cpdata'):
|
||||
engine = create_engine(database_url, echo=False)
|
||||
query = sa.text('SELECT delta,cp from cpdata WHERE user={rower_id};'.format(
|
||||
rower_id=rower_id
|
||||
query = sa.text('SELECT * from {table} WHERE user={rower_id};'.format(
|
||||
rower_id=rower_id,
|
||||
table=table,
|
||||
))
|
||||
connection = engine.raw_connection()
|
||||
df = pd.read_sql_query(query, engine)
|
||||
|
||||
return df
|
||||
|
||||
def deletecpdata_sql(rower_id):
|
||||
def deletecpdata_sql(rower_id,table='cpdata'):
|
||||
engine = create_engine(database_url, echo=False)
|
||||
query = sa.text('DELETE from cpdata WHERE user={rower_id};'.format(
|
||||
rower_id=rower_id
|
||||
query = sa.text('DELETE from {table} WHERE user={rower_id};'.format(
|
||||
rower_id=rower_id,
|
||||
table=table,
|
||||
))
|
||||
with engine.connect() as conn, conn.begin():
|
||||
try:
|
||||
@@ -451,7 +453,7 @@ def deletecpdata_sql(rower_id):
|
||||
|
||||
|
||||
|
||||
def updatecpdata_sql(rower_id,delta,cp):
|
||||
def updatecpdata_sql(rower_id,delta,cp,table='cpdata',distance=[]):
|
||||
deletecpdata_sql(rower_id)
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
@@ -461,9 +463,12 @@ def updatecpdata_sql(rower_id,delta,cp):
|
||||
}
|
||||
)
|
||||
|
||||
if not distance.empty:
|
||||
df['distance'] = distance
|
||||
|
||||
engine = create_engine(database_url, echo=False)
|
||||
with engine.connect() as conn, conn.begin():
|
||||
df.to_sql('cpdata', engine, if_exists='append', index=False)
|
||||
df.to_sql(table, engine, if_exists='append', index=False)
|
||||
conn.close()
|
||||
engine.dispose()
|
||||
|
||||
@@ -484,7 +489,19 @@ def runcpupdate(rower):
|
||||
else:
|
||||
res = queue.enqueue(handle_updatecp,rower.id,theids)
|
||||
|
||||
|
||||
def fetchcperg(rower,theworkouts):
|
||||
theids = [int(w.id) for w in theworkouts]
|
||||
thefilenames = [w.csvfilename for w in theworkouts]
|
||||
cpdf = getcpdata_sql(rower.id,table='ergcpdata')
|
||||
|
||||
if settings.DEBUG:
|
||||
res = handle_updateergcp.delay(rower.id,thefilenames,debug=True)
|
||||
else:
|
||||
res = queue.enqueue(handle_updateergcp,rower.id,thefilenames)
|
||||
|
||||
return cpdf
|
||||
|
||||
|
||||
def fetchcp(rower,theworkouts):
|
||||
# get all power data from database (plus workoutid)
|
||||
theids = [int(w.id) for w in theworkouts]
|
||||
|
||||
Reference in New Issue
Block a user