diff --git a/rowers/templates/history.html b/rowers/templates/history.html
index 8f84dcfd..0b775cdb 100644
--- a/rowers/templates/history.html
+++ b/rowers/templates/history.html
@@ -58,16 +58,16 @@
Number of workouts | {{ totalsdict|lookup:"nrworkouts"}} |
- | Average heart rate | {{ totalsdict|lookup:"hrmean"}} bpm |
+ Average heart rate | bpm |
- | Maximum heart rate | {{ totalsdict|lookup:"hrmax"}} bpm |
+ Maximum heart rate | bpm |
- | Average power | {{ totalsdict|lookup:"powermean"}} W |
+ Average power | W |
- | Maximum power | {{ totalsdict|lookup:"powermax"}} W |
+ Maximum power | W |
@@ -125,17 +125,21 @@
diff --git a/rowers/views/analysisviews.py b/rowers/views/analysisviews.py
index 84e18a4f..98f4d145 100644
--- a/rowers/views/analysisviews.py
+++ b/rowers/views/analysisviews.py
@@ -4697,14 +4697,6 @@ def history_view(request,userid=0):
columns = ['hr','power','time']
- 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)
totalminutes = "{totalminutes:02d}".format(totalminutes=totalminutes)
@@ -4740,7 +4732,7 @@ def history_view(request,userid=0):
ddict['hrmean'] = int(wavg(ddf,'hr','deltat'))
ddict['hrmax'] = ddf['hr'].max().astype(int)
- ddict['powermean'] = int(wavg(df,'power','deltat'))
+ ddict['powermean'] = int(wavg(ddf,'power','deltat'))
ddict['powermax'] = ddf['power'].max().astype(int)
ddict['nrworkouts'] = a_workouts.count()
listofdicts.append(ddict)
@@ -4772,18 +4764,7 @@ def history_view(request,userid=0):
)
totalsdict['distance'] = totalmeters
- try:
- totalsdict['powermean'] = int(wavg(df,'power','deltat'))
- totalsdict['powermax'] = df['power'].max().astype(int)
- except KeyError:
- totalsdict['powermean'] = 0
- totalsdict['powermax'] = 0
- try:
- totalsdict['hrmean'] = int(wavg(df,'hr','deltat'))
- totalsdict['hrmax'] = df['hr'].max().astype(int)
- except KeyError:
- totalsdict['hrmean'] = 0
- totalsdict['hrmax'] = 0
+
totalsdict['nrworkouts'] = g_workouts.count()
@@ -4874,7 +4855,64 @@ def history_view_data(request,userid=0):
df = dataprep.clean_df_stats(df,workstrokesonly=True,
ignoreadvanced=True)
+ totalmeters,totalhours, totalminutes = get_totals(g_workouts)
+ totalminutes = "{totalminutes:02d}".format(totalminutes=totalminutes)
+ # meters, duration per workout type
+ wtypes = list(set([w.workouttype for w in g_workouts]))
+
+ typechoices = [("All","All")]
+ for wtype in wtypes:
+ typechoices.append((wtype,mytypes.workouttypes_ordered[wtype]))
+
+ listofdicts = []
+
+ for wtype in wtypes:
+ a_workouts = g_workouts.filter(workouttype=wtype)
+ wmeters, whours, wminutes = get_totals(a_workouts)
+ ddict = {}
+ ddict['wtype'] = mytypes.workouttypes_ordered[wtype]
+ ddict['distance'] = wmeters
+ ddict['duration'] = "{whours}:{wminutes:02d}".format(
+ whours=whours,
+ wminutes=wminutes
+ )
+ 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)
+
+ ddict['hrmean'] = int(wavg(ddf,'hr','deltat'))
+ ddict['hrmax'] = ddf['hr'].max().astype(int)
+ ddict['powermean'] = int(wavg(df,'power','deltat'))
+ ddict['powermax'] = ddf['power'].max().astype(int)
+ ddict['nrworkouts'] = a_workouts.count()
+ listofdicts.append(ddict)
+
+ totalsdict = {}
+ totalsdict['duration'] = "{totalhours}:{totalminutes}".format(
+ totalhours=totalhours,
+ totalminutes=totalminutes
+ )
+
+ totalsdict['distance'] = totalmeters
+ try:
+ totalsdict['powermean'] = int(wavg(df,'power','deltat'))
+ totalsdict['powermax'] = df['power'].max().astype(int)
+ except KeyError:
+ totalsdict['powermean'] = 0
+ totalsdict['powermax'] = 0
+ try:
+ totalsdict['hrmean'] = int(wavg(df,'hr','deltat'))
+ totalsdict['hrmax'] = df['hr'].max().astype(int)
+ except KeyError:
+ totalsdict['hrmean'] = 0
+ totalsdict['hrmax'] = 0
+
+ totalsdict['nrworkouts'] = g_workouts.count()
# interactive hr pie chart
@@ -4894,4 +4932,6 @@ def history_view_data(request,userid=0):
return JSONResponse({
'script':totalscript,
'div':totaldiv,
+ 'totalsdict':totalsdict,
+ 'listofdicts':listofdicts,
})