aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2025-12-26 00:37:21 +0100
committerDaniel Schadt <kingdread@gmx.de>2025-12-30 19:16:32 +0100
commita00cea3286310c93f55dc678335e6d4d8ea2d850 (patch)
tree2189c085acf576a10fb8159370e33d32d71b55db
parent4f41f3bc47746d867feedbd4ab16d8a6b53fd4d2 (diff)
downloadfietsboek-a00cea3286310c93f55dc678335e6d4d8ea2d850.tar.gz
fietsboek-a00cea3286310c93f55dc678335e6d4d8ea2d850.tar.bz2
fietsboek-a00cea3286310c93f55dc678335e6d4d8ea2d850.zip
show more stats for journey
-rw-r--r--fietsboek/models/journey.py10
-rw-r--r--fietsboek/templates/journey_details.jinja216
-rw-r--r--fietsboek/views/journey.py2
3 files changed, 26 insertions, 2 deletions
diff --git a/fietsboek/models/journey.py b/fietsboek/models/journey.py
index 512146f..d90db55 100644
--- a/fietsboek/models/journey.py
+++ b/fietsboek/models/journey.py
@@ -1,4 +1,4 @@
-import datetime
+import dataclasses
import io
import logging
import enum
@@ -149,7 +149,13 @@ class Journey(Base):
def path(self) -> geo.Path:
"""Returns the concatenated path of all contained tracks."""
- points = [point for track in self.tracks for point in track.path().points]
+ offset = 0.0
+ points = []
+ for track in self.tracks:
+ for point in track.path().points:
+ new_point = dataclasses.replace(point, time_offset=point.time_offset + offset)
+ points.append(new_point)
+ offset += point.time_offset
return geo.Path(points)
def gpx_xml(self) -> bytes:
diff --git a/fietsboek/templates/journey_details.jinja2 b/fietsboek/templates/journey_details.jinja2
index bc8137e..01d94c1 100644
--- a/fietsboek/templates/journey_details.jinja2
+++ b/fietsboek/templates/journey_details.jinja2
@@ -77,6 +77,22 @@
<th scope="row">{{ _("page.details.downhill") }}</th>
<td id="detailsDownhill">{{ movement_data.downhill | round(2) | format_decimal }} m</td>
</tr>
+ <tr>
+ <th scope="row">{{ _("page.details.moving_time") }}</th>
+ <td id="detailsDownhill">{{ timedelta(seconds=movement_data.moving_duration) }}</td>
+ </tr>
+ <tr>
+ <th scope="row">{{ _("page.details.stopped_time") }}</th>
+ <td id="detailsDownhill">{{ timedelta(seconds=movement_data.stopped_duration) }}</td>
+ </tr>
+ <tr>
+ <th scope="row">{{ _("page.details.max_speed") }}</th>
+ <td id="detailsDownhill">{{ mps_to_kph(movement_data.maximum_speed) | round(2) | format_decimal }} km/h</td>
+ </tr>
+ <tr>
+ <th scope="row">{{ _("page.details.avg_speed") }}</th>
+ <td id="detailsDownhill">{{ mps_to_kph(movement_data.average_speed) | round(2) | format_decimal }} km/h</td>
+ </tr>
</tbody>
</table>
diff --git a/fietsboek/views/journey.py b/fietsboek/views/journey.py
index 2b14c22..28df29e 100644
--- a/fietsboek/views/journey.py
+++ b/fietsboek/views/journey.py
@@ -1,5 +1,6 @@
import io
import logging
+from datetime import timedelta
from pyramid.httpexceptions import HTTPBadRequest, HTTPFound
from pyramid.request import Request
from pyramid.response import Response
@@ -42,6 +43,7 @@ def journey_details(request: Request):
"movement_data": movement_data,
"mps_to_kph": util.mps_to_kph,
"md_to_html": util.safe_markdown,
+ "timedelta": timedelta,
"show_edit_link": show_edit_link,
}