adding try and except
This commit is contained in:
@@ -4695,9 +4695,16 @@ def history_view(request,userid=0):
|
|||||||
|
|
||||||
ids = [w.id for w in g_workouts]
|
ids = [w.id for w in g_workouts]
|
||||||
|
|
||||||
columns = ['hr','power']
|
columns = ['hr','power','time']
|
||||||
|
|
||||||
df = getsmallrowdata_db(columns,ids=ids)
|
df = getsmallrowdata_db(columns,ids=ids)
|
||||||
|
try:
|
||||||
|
df['deltat'] = df['time'].diff()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
df = dataprep.clean_df_stats(df,workstrokesonly=True,
|
||||||
|
ignoreadvanced=True)
|
||||||
|
|
||||||
|
|
||||||
totalmeters,totalhours, totalminutes = get_totals(g_workouts)
|
totalmeters,totalhours, totalminutes = get_totals(g_workouts)
|
||||||
|
|
||||||
@@ -4723,9 +4730,16 @@ def history_view(request,userid=0):
|
|||||||
wminutes=wminutes
|
wminutes=wminutes
|
||||||
)
|
)
|
||||||
ddf = getsmallrowdata_db(columns,ids=[w.id for w in a_workouts])
|
ddf = getsmallrowdata_db(columns,ids=[w.id for w in a_workouts])
|
||||||
ddict['hrmean'] = ddf['hr'].mean().astype(int)
|
try:
|
||||||
|
ddf['deltat'] = ddf['time'].diff()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
ddf = dataprep.clean_df_stats(ddf,workstrokesonly=True,
|
||||||
|
ignoreadvanced=True)
|
||||||
|
|
||||||
|
ddict['hrmean'] = int(wavg(ddf,'hr','deltat'))
|
||||||
ddict['hrmax'] = ddf['hr'].max().astype(int)
|
ddict['hrmax'] = ddf['hr'].max().astype(int)
|
||||||
ddict['powermean'] = ddf['power'].mean().astype(int)
|
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()
|
||||||
listofdicts.append(ddict)
|
listofdicts.append(ddict)
|
||||||
@@ -4737,6 +4751,12 @@ def history_view(request,userid=0):
|
|||||||
else:
|
else:
|
||||||
a_workouts = g_workouts.filter(workouttype=typeselect)
|
a_workouts = g_workouts.filter(workouttype=typeselect)
|
||||||
ddf = getsmallrowdata_db(columns,ids=[w.id for w in a_workouts])
|
ddf = getsmallrowdata_db(columns,ids=[w.id for w in a_workouts])
|
||||||
|
try:
|
||||||
|
ddf['deltat'] = ddf['time'].diff()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
ddf = dataprep.clean_df_stats(ddf,workstrokesonly=True,
|
||||||
|
ignoreadvanced=True)
|
||||||
totalscript, totaldiv = interactive_hr_piechart(ddf,r,mytypes.workouttypes_ordered[typeselect])
|
totalscript, totaldiv = interactive_hr_piechart(ddf,r,mytypes.workouttypes_ordered[typeselect])
|
||||||
|
|
||||||
# interactive power pie chart
|
# interactive power pie chart
|
||||||
@@ -4749,13 +4769,13 @@ def history_view(request,userid=0):
|
|||||||
|
|
||||||
totalsdict['distance'] = totalmeters
|
totalsdict['distance'] = totalmeters
|
||||||
try:
|
try:
|
||||||
totalsdict['powermean'] = df['power'].mean().astype(int)
|
totalsdict['powermean'] = int(wavg(df,'power','deltat'))
|
||||||
totalsdict['powermax'] = df['power'].max().astype(int)
|
totalsdict['powermax'] = df['power'].max().astype(int)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
totalsdict['powermean'] = 0
|
totalsdict['powermean'] = 0
|
||||||
totalsdict['powermax'] = 0
|
totalsdict['powermax'] = 0
|
||||||
try:
|
try:
|
||||||
totalsdict['hrmean'] = df['hr'].mean().astype(int)
|
totalsdict['hrmean'] = int(wavg(df,'hr','deltat'))
|
||||||
totalsdict['hrmax'] = df['hr'].max().astype(int)
|
totalsdict['hrmax'] = df['hr'].max().astype(int)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
totalsdict['hrmean'] = 0
|
totalsdict['hrmean'] = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user