diff --git a/rowers/templates/history.html b/rowers/templates/history.html index 0b775cdb..c7507a58 100644 --- a/rowers/templates/history.html +++ b/rowers/templates/history.html @@ -96,16 +96,16 @@ Number of workouts{{ ddict|lookup:"nrworkouts"}} - Average heart rate{{ ddict|lookup:"hrmean"}} bpm + Average heart rate bpm - Maximum heart rate{{ ddict|lookup:"hrmax"}} bpm + Maximum heart rate bpm - Average power{{ ddict|lookup:"powermean"}} W + Average power W - Maximum power{{ ddict|lookup:"powermax"}} W + Maximum power W @@ -131,6 +131,7 @@ var script = json.script; var div = json.div; var totalsdict = json.totalsdict + var listofdicts = json.listofdicts $("#id_sitready").remove(); $("#id_chart").append(div); console.log(div); @@ -140,6 +141,16 @@ $("#total_maxhr").append(totalsdict.hrmax); $("#total_power").append(totalsdict.powermean); $("#total_maxpower").append(totalsdict.powermax); + listofdicts.forEach(function(item){ + var id = "#"+item.id+"_hr"; + $(id).append(item.hrmean); + id = "#"+item.id+"_hrmax"; + $(id).append(item.hrmax); + id = "#"+item.id+"_power"; + $(id).append(item.powermean); + id = "#"+item.id+"_powermax"; + $(id).append(item.powermax); + }) }); }); diff --git a/rowers/views/analysisviews.py b/rowers/views/analysisviews.py index 98f4d145..d2293e28 100644 --- a/rowers/views/analysisviews.py +++ b/rowers/views/analysisviews.py @@ -4716,24 +4716,13 @@ def history_view(request,userid=0): a_workouts = g_workouts.filter(workouttype=wtype) wmeters, whours, wminutes = get_totals(a_workouts) ddict = {} + ddict['id'] = wtype 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(ddf,'power','deltat')) - ddict['powermax'] = ddf['power'].max().astype(int) ddict['nrworkouts'] = a_workouts.count() listofdicts.append(ddict) @@ -4741,22 +4730,7 @@ def history_view(request,userid=0): # interactive hr pie chart totalscript = '' totaldiv = get_call() - if typeselect == 'All': - pass - #totalscript,totaldiv = interactive_hr_piechart(df,r,'All Workouts') - else: - a_workouts = g_workouts.filter(workouttype=typeselect) - 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]) - - # interactive power pie chart - + totalsdict = {} totalsdict['duration'] = "{totalhours}:{totalminutes}".format( totalhours=totalhours, @@ -4872,6 +4846,7 @@ def history_view_data(request,userid=0): wmeters, whours, wminutes = get_totals(a_workouts) ddict = {} ddict['wtype'] = mytypes.workouttypes_ordered[wtype] + ddict['id'] = wtype ddict['distance'] = wmeters ddict['duration'] = "{whours}:{wminutes:02d}".format( whours=whours,