Skip to content

Commit f4c900d

Browse files
committed
Totals row for activity page
1 parent ab4946f commit f4c900d

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

Diff for: vzdv-site/src/endpoints/facility.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,20 @@ async fn page_activity(
360360
});
361361
}
362362

363+
// summary row for the bottom
364+
let totals = activity_data.iter().fold((0, 0, 0, 0, 0), |acc, row| {
365+
(
366+
acc.0 + row.months.first().map(|am| am.value).unwrap_or_default(),
367+
acc.1 + row.months.get(1).map(|am| am.value).unwrap_or_default(),
368+
acc.2 + row.months.get(2).map(|am| am.value).unwrap_or_default(),
369+
acc.3 + row.months.get(3).map(|am| am.value).unwrap_or_default(),
370+
acc.4 + row.months.get(4).map(|am| am.value).unwrap_or_default(),
371+
)
372+
});
373+
363374
let user_info: Option<UserInfo> = session.get(SESSION_USER_INFO_KEY).await?;
364375
let template = state.templates.get_template("facility/activity.jinja")?;
365-
let rendered = template.render(context! { user_info, activity_data })?;
376+
let rendered = template.render(context! { user_info, activity_data, totals })?;
366377
Ok(Html(rendered))
367378
}
368379

Diff for: vzdv-site/templates/changelog.jinja

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414

1515
<hr>
1616

17+
<div class="card shadow mb-3">
18+
<div class="card-body">
19+
<h5 class="card-title">2025-01-24</h5>
20+
<div class="card-text">
21+
<ul>
22+
<li>Activity page "totals" row</li>
23+
</ul>
24+
</div>
25+
</div>
26+
</div>
27+
1728
<div class="card shadow mb-3">
1829
<div class="card-body">
1930
<h5 class="card-title">2025-01-22</h5>

Diff for: vzdv-site/templates/facility/activity.jinja

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
{% endfor %}
4343
</tr>
4444
{% endfor %}
45+
<tr>
46+
<td><strong>Totals</strong></td>
47+
{% for month in totals %}
48+
<td>{{ month|minutes_to_hm }}</td>
49+
{% endfor %}
50+
</tr>
4551
</tbody>
4652
</table>
4753

0 commit comments

Comments
 (0)