added totals to planned sessions view
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<h1>Planned Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
<h1>Planned Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
<li>
|
<li class="grid_2">
|
||||||
<p>
|
<p>
|
||||||
<form enctype="multipart/form-data" method="get">
|
<form enctype="multipart/form-data" method="get">
|
||||||
<table>
|
<table>
|
||||||
@@ -172,6 +172,82 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
<p>
|
||||||
|
<table width="90%" class="listtable shortpadded">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th>Distance</th>
|
||||||
|
<th>Time (minutes)</th>
|
||||||
|
<th>rScore</th>
|
||||||
|
<th>TRIMP</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Total
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'distance' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'time' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'rscore' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'trimp' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Planned
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'planneddistance' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'plannedtime' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'plannedrscore' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'plannedtrimp' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Actual
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'actualdistance' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'actualtime' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'actualrscore' }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ totals|lookup:'actualtrimp' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Total is the total minutes, meters, rScore, TRIMP of all workouts in this
|
||||||
|
time period.
|
||||||
|
Planned time is the total time for sessions planned for time.
|
||||||
|
Actual time is the total time of workouts linked to sessions
|
||||||
|
planned for time.
|
||||||
|
Similarly for distance, rScore and TRIMP.
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15297,6 +15297,46 @@ def plannedsessions_view(request,
|
|||||||
completiondate = {}
|
completiondate = {}
|
||||||
sessioncolor = {}
|
sessioncolor = {}
|
||||||
|
|
||||||
|
totals = {
|
||||||
|
'trimp':0,
|
||||||
|
'rscore':0,
|
||||||
|
'distance':0,
|
||||||
|
'time':0,
|
||||||
|
'plannedtime':0,
|
||||||
|
'planneddistance':0,
|
||||||
|
'plannedtrimp':0,
|
||||||
|
'plannedrscore':0,
|
||||||
|
'actualtime':0,
|
||||||
|
'actualdistance':0,
|
||||||
|
'actualtrimp':0,
|
||||||
|
'actualrscore':0,
|
||||||
|
}
|
||||||
|
|
||||||
|
ws = Workout.objects.filter(
|
||||||
|
user=r,
|
||||||
|
date__gte=startdate,date__lte=enddate)
|
||||||
|
|
||||||
|
for w in ws:
|
||||||
|
thetrimp,hrtss = dataprep.workout_trimp(w)
|
||||||
|
totals['trimp'] += thetrimp
|
||||||
|
tss = dataprep.workout_rscore(w)[0]
|
||||||
|
if not np.isnan(tss) and tss != 0:
|
||||||
|
totals['rscore'] += tss
|
||||||
|
elif tss == 0:
|
||||||
|
totals['rscore'] += hrtss
|
||||||
|
tss = hrtss
|
||||||
|
totals['distance'] += w.distance
|
||||||
|
totals['time'] += timefield_to_seconds_duration(w.duration)
|
||||||
|
if w.plannedsession:
|
||||||
|
if w.plannedsession.sessionmode == 'distance':
|
||||||
|
totals['actualdistance'] += w.distance
|
||||||
|
elif w.plannedsession.sessionmode == 'time':
|
||||||
|
totals['actualtime'] += timefield_to_seconds_duration(w.duration)
|
||||||
|
elif w.plannedsession.sessionmode == 'rScore':
|
||||||
|
totals['actualrscore'] += tss
|
||||||
|
elif w.plannedsession.sessionmode == 'TRIMP':
|
||||||
|
totals['actualtrimp'] += thetrimp
|
||||||
|
|
||||||
if not sps and request.user.rower.rowerplan == 'basic':
|
if not sps and request.user.rower.rowerplan == 'basic':
|
||||||
messages.error(request,
|
messages.error(request,
|
||||||
"You must purchase Coach or Self-coach plans or be part of a team to get planned sessions")
|
"You must purchase Coach or Self-coach plans or be part of a team to get planned sessions")
|
||||||
@@ -15308,7 +15348,19 @@ def plannedsessions_view(request,
|
|||||||
sessioncolor[ps.id] = cratiocolors[status]
|
sessioncolor[ps.id] = cratiocolors[status]
|
||||||
ws = Workout.objects.filter(user=r,plannedsession=ps)
|
ws = Workout.objects.filter(user=r,plannedsession=ps)
|
||||||
completiondate[ps.id] = cdate
|
completiondate[ps.id] = cdate
|
||||||
|
if ps.sessionmode == 'distance':
|
||||||
|
totals['planneddistance'] += ps.sessionvalue
|
||||||
|
elif ps.sessionmode == 'time':
|
||||||
|
totals['plannedtime'] += ps.sessionvalue
|
||||||
|
elif ps.sessionmode == 'rScore':
|
||||||
|
totals['plannedrscore'] += ps.sessionvalue
|
||||||
|
elif ps.sessionmode == 'TRIMP':
|
||||||
|
totals['plannedtrimp'] += ps.sessionvalue
|
||||||
|
|
||||||
|
totals['time'] = int(totals['time']/60.)
|
||||||
|
totals['actualtime'] = int(totals['actualtime']/60.)
|
||||||
|
totals['plannedtime'] = int(totals['plannedtime']/60.)
|
||||||
|
|
||||||
unmatchedworkouts = Workout.objects.filter(
|
unmatchedworkouts = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
plannedsession=None,
|
plannedsession=None,
|
||||||
@@ -15338,6 +15390,7 @@ def plannedsessions_view(request,
|
|||||||
'plan':trainingplan,
|
'plan':trainingplan,
|
||||||
'active': 'nav-plan',
|
'active': 'nav-plan',
|
||||||
'dateform':dateform,
|
'dateform':dateform,
|
||||||
|
'totals':totals,
|
||||||
'rower':r,
|
'rower':r,
|
||||||
'timeperiod':timeperiod,
|
'timeperiod':timeperiod,
|
||||||
'completeness':completeness,
|
'completeness':completeness,
|
||||||
|
|||||||
Reference in New Issue
Block a user