Private
Public Access
1
0

fixing bugs in asynchronous tasks

This commit is contained in:
Sander Roosendaal
2019-12-22 20:13:30 +01:00
parent 724720aa39
commit 8109eee75f
2 changed files with 10 additions and 6 deletions

View File

@@ -715,6 +715,8 @@ def getsmallrowdata_db(columns,ids=[],debug=False):
data = []
columns = [c for c in columns if c != 'None']
df = pd.DataFrame()
if len(ids)>1:
for id, f in zip(ids,csvfilenames):
try:
@@ -728,11 +730,13 @@ def getsmallrowdata_db(columns,ids=[],debug=False):
df = pd.concat(data,axis=0)
except ValueError:
df = pd.DataFrame()
else:
elif len(ids)==1:
try:
df = pd.read_parquet(csvfilenames[0],columns=columns,engine='pyarrow')
except (OSError,IndexError):
df = pd.DataFrame()
else:
df = pd.DataFrame()
return df

View File

@@ -1754,15 +1754,15 @@ def handle_updatefitnessmetric(user_id,mode,workoutids,debug=False,
def handle_updatecp(rower_id,workoutids,debug=False,table='cpdata',**kwargs):
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.
if df.empty:
return 0
maxt = 1.05*df['time'].max()/1000.
logarr = datautils.getlogarr(maxt)
dfgrouped = df.groupby(['workoutid'])
delta,cpvalue,avgpower = datautils.getcp(dfgrouped,logarr)