From 6581d947c212b46d22f0fbb17afa80394faf2521 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 25 Mar 2023 13:46:45 +0100 Subject: add number of tracks to profile --- fietsboek/templates/profile.jinja2 | 4 ++++ fietsboek/views/profile.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/fietsboek/templates/profile.jinja2 b/fietsboek/templates/profile.jinja2 index 34bb2de..5170109 100644 --- a/fietsboek/templates/profile.jinja2 +++ b/fietsboek/templates/profile.jinja2 @@ -36,6 +36,10 @@ {{ _("page.details.avg_speed") }} {{ mps_to_kph(avg_speed) | round(2) | format_decimal }} km/h + + {{ _("page.profile.number_of_tracks") }} + {{ number_of_tracks }} + {% endblock %} diff --git a/fietsboek/views/profile.py b/fietsboek/views/profile.py index 6bd566a..657f955 100644 --- a/fietsboek/views/profile.py +++ b/fietsboek/views/profile.py @@ -38,6 +38,7 @@ def profile(request: Request) -> dict: total_moving_time = datetime.timedelta(0) total_stopped_time = datetime.timedelta(0) max_speed = 0.0 + number_of_tracks = 0 track: models.Track for track in request.context.tracks: @@ -52,6 +53,7 @@ def profile(request: Request) -> dict: total_moving_time += meta.moving_time total_stopped_time += meta.stopped_time max_speed = max(max_speed, meta.max_speed) + number_of_tracks += 1 avg_speed = total_length / total_moving_time.total_seconds() total_moving_time = round_to_seconds(total_moving_time) @@ -99,6 +101,7 @@ def profile(request: Request) -> dict: "max_speed": max_speed, "avg_speed": avg_speed, "mps_to_kph": util.mps_to_kph, + "number_of_tracks": number_of_tracks, "heatmap_url": heatmap_url, "tilehunt_url": tilehunt_url, } -- cgit v1.2.3