From 77f0b17b37742592178d20c7bbb593d4ab8cd28f Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Thu, 12 Dec 2024 20:47:21 +0000 Subject: [PATCH] Bug fix trip stats page --- templates/trip/stats.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/templates/trip/stats.html b/templates/trip/stats.html index 8a117ef..7d81a3d 100644 --- a/templates/trip/stats.html +++ b/templates/trip/stats.html @@ -31,20 +31,24 @@ {% endfor %}
- Flight segments in {{ year }}: {{ year_stats.flight_count }} + Flight segments in {{ year }}: {{ year_stats.flight_count or 0 }} + {% if year_stats.airlines %} [ by airline: - {% for airline, count in year_stats.airlines.most_common() %} - {{ airline }}: {{ count }}{% if not loop.last %},{% endif %} - {% endfor %} ] + {% for airline, count in year_stats.airlines.most_common() %} + {{ airline }}: {{ count }}{% if not loop.last %},{% endif %} + {% endfor %} ] + {% endif %}
-
Trains segments in {{ year }}: {{ year_stats.train_count }}
-
Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}
+
Trains segments in {{ year }}: {{ year_stats.train_count or 0 }}
+
Total distance in {{ year}}: {{ format_distance(year_stats.total_distance or 0) }}
+ {% if year_stats.distances_by_transport_type %} {% for transport_type, distance in year_stats.distances_by_transport_type.items() %}
{{ transport_type | title }} distance: {{format_distance(distance) }}
{% endfor %} + {% endif %} {% endfor %} {% endblock %}