fixing bugs in asynchronous tasks
This commit is contained in:
@@ -715,6 +715,8 @@ def getsmallrowdata_db(columns,ids=[],debug=False):
|
|||||||
data = []
|
data = []
|
||||||
columns = [c for c in columns if c != 'None']
|
columns = [c for c in columns if c != 'None']
|
||||||
|
|
||||||
|
df = pd.DataFrame()
|
||||||
|
|
||||||
if len(ids)>1:
|
if len(ids)>1:
|
||||||
for id, f in zip(ids,csvfilenames):
|
for id, f in zip(ids,csvfilenames):
|
||||||
try:
|
try:
|
||||||
@@ -728,11 +730,13 @@ def getsmallrowdata_db(columns,ids=[],debug=False):
|
|||||||
df = pd.concat(data,axis=0)
|
df = pd.concat(data,axis=0)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
df = pd.DataFrame()
|
df = pd.DataFrame()
|
||||||
else:
|
elif len(ids)==1:
|
||||||
try:
|
try:
|
||||||
df = pd.read_parquet(csvfilenames[0],columns=columns,engine='pyarrow')
|
df = pd.read_parquet(csvfilenames[0],columns=columns,engine='pyarrow')
|
||||||
except (OSError,IndexError):
|
except (OSError,IndexError):
|
||||||
df = pd.DataFrame()
|
df = pd.DataFrame()
|
||||||
|
else:
|
||||||
|
df = pd.DataFrame()
|
||||||
|
|
||||||
|
|
||||||
return df
|
return df
|
||||||
|
|||||||
@@ -1754,15 +1754,15 @@ def handle_updatefitnessmetric(user_id,mode,workoutids,debug=False,
|
|||||||
def handle_updatecp(rower_id,workoutids,debug=False,table='cpdata',**kwargs):
|
def handle_updatecp(rower_id,workoutids,debug=False,table='cpdata',**kwargs):
|
||||||
columns = ['power','workoutid','time']
|
columns = ['power','workoutid','time']
|
||||||
df = getsmallrowdata_db(columns,ids=workoutids,debug=debug)
|
df = getsmallrowdata_db(columns,ids=workoutids,debug=debug)
|
||||||
dfgrouped = df.groupby(['workoutid'])
|
|
||||||
|
|
||||||
if not df.empty:
|
if df.empty:
|
||||||
maxt = 1.05*df['time'].max()/1000.
|
return 0
|
||||||
else:
|
|
||||||
maxt = 1000.
|
maxt = 1.05*df['time'].max()/1000.
|
||||||
|
|
||||||
logarr = datautils.getlogarr(maxt)
|
logarr = datautils.getlogarr(maxt)
|
||||||
|
|
||||||
|
dfgrouped = df.groupby(['workoutid'])
|
||||||
|
|
||||||
delta,cpvalue,avgpower = datautils.getcp(dfgrouped,logarr)
|
delta,cpvalue,avgpower = datautils.getcp(dfgrouped,logarr)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user