all dicts through ajax
This commit is contained in:
@@ -96,16 +96,16 @@
|
|||||||
<td>Number of workouts</td><td>{{ ddict|lookup:"nrworkouts"}}</td>
|
<td>Number of workouts</td><td>{{ ddict|lookup:"nrworkouts"}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Average heart rate</td><td>{{ ddict|lookup:"hrmean"}} bpm</td>
|
<td>Average heart rate</td><td><span id="{{ ddict|lookup:'id'}}_hr"></span> bpm</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Maximum heart rate</td><td>{{ ddict|lookup:"hrmax"}} bpm</td>
|
<td>Maximum heart rate</td><td><span id="{{ ddict|lookup:'id' }}_hrmax"></span> bpm</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Average power</td><td>{{ ddict|lookup:"powermean"}} W</td>
|
<td>Average power</td><td><span id="{{ ddict|lookup:'id'}}_power"></span> W</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Maximum power</td><td>{{ ddict|lookup:"powermax"}} W</td>
|
<td>Maximum power</td><td><span id="{{ ddict|lookup:'id'}}_powermax"></span> W</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -131,6 +131,7 @@
|
|||||||
var script = json.script;
|
var script = json.script;
|
||||||
var div = json.div;
|
var div = json.div;
|
||||||
var totalsdict = json.totalsdict
|
var totalsdict = json.totalsdict
|
||||||
|
var listofdicts = json.listofdicts
|
||||||
$("#id_sitready").remove();
|
$("#id_sitready").remove();
|
||||||
$("#id_chart").append(div);
|
$("#id_chart").append(div);
|
||||||
console.log(div);
|
console.log(div);
|
||||||
@@ -140,6 +141,16 @@
|
|||||||
$("#total_maxhr").append(totalsdict.hrmax);
|
$("#total_maxhr").append(totalsdict.hrmax);
|
||||||
$("#total_power").append(totalsdict.powermean);
|
$("#total_power").append(totalsdict.powermean);
|
||||||
$("#total_maxpower").append(totalsdict.powermax);
|
$("#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);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4716,24 +4716,13 @@ def history_view(request,userid=0):
|
|||||||
a_workouts = g_workouts.filter(workouttype=wtype)
|
a_workouts = g_workouts.filter(workouttype=wtype)
|
||||||
wmeters, whours, wminutes = get_totals(a_workouts)
|
wmeters, whours, wminutes = get_totals(a_workouts)
|
||||||
ddict = {}
|
ddict = {}
|
||||||
|
ddict['id'] = wtype
|
||||||
ddict['wtype'] = mytypes.workouttypes_ordered[wtype]
|
ddict['wtype'] = mytypes.workouttypes_ordered[wtype]
|
||||||
ddict['distance'] = wmeters
|
ddict['distance'] = wmeters
|
||||||
ddict['duration'] = "{whours}:{wminutes:02d}".format(
|
ddict['duration'] = "{whours}:{wminutes:02d}".format(
|
||||||
whours=whours,
|
whours=whours,
|
||||||
wminutes=wminutes
|
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()
|
ddict['nrworkouts'] = a_workouts.count()
|
||||||
listofdicts.append(ddict)
|
listofdicts.append(ddict)
|
||||||
|
|
||||||
@@ -4741,21 +4730,6 @@ def history_view(request,userid=0):
|
|||||||
# interactive hr pie chart
|
# interactive hr pie chart
|
||||||
totalscript = ''
|
totalscript = ''
|
||||||
totaldiv = get_call()
|
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 = {}
|
||||||
totalsdict['duration'] = "{totalhours}:{totalminutes}".format(
|
totalsdict['duration'] = "{totalhours}:{totalminutes}".format(
|
||||||
@@ -4872,6 +4846,7 @@ def history_view_data(request,userid=0):
|
|||||||
wmeters, whours, wminutes = get_totals(a_workouts)
|
wmeters, whours, wminutes = get_totals(a_workouts)
|
||||||
ddict = {}
|
ddict = {}
|
||||||
ddict['wtype'] = mytypes.workouttypes_ordered[wtype]
|
ddict['wtype'] = mytypes.workouttypes_ordered[wtype]
|
||||||
|
ddict['id'] = wtype
|
||||||
ddict['distance'] = wmeters
|
ddict['distance'] = wmeters
|
||||||
ddict['duration'] = "{whours}:{wminutes:02d}".format(
|
ddict['duration'] = "{whours}:{wminutes:02d}".format(
|
||||||
whours=whours,
|
whours=whours,
|
||||||
|
|||||||
Reference in New Issue
Block a user