Bug fix trip stats page

This commit is contained in:
Edward Betts 2024-12-12 20:47:21 +00:00
parent f6d715e52a
commit 77f0b17b37

View file

@ -31,20 +31,24 @@
{% endfor %} {% endfor %}
</div> </div>
<div> <div>
Flight segments in {{ year }}: {{ year_stats.flight_count }} Flight segments in {{ year }}: {{ year_stats.flight_count or 0 }}
{% if year_stats.airlines %}
[ by airline: [ by airline:
{% for airline, count in year_stats.airlines.most_common() %} {% for airline, count in year_stats.airlines.most_common() %}
{{ airline }}: {{ count }}{% if not loop.last %},{% endif %} {{ airline }}: {{ count }}{% if not loop.last %},{% endif %}
{% endfor %} ] {% endfor %} ]
{% endif %}
</div> </div>
<div>Trains segments in {{ year }}: {{ year_stats.train_count }}</div> <div>Trains segments in {{ year }}: {{ year_stats.train_count or 0 }}</div>
<div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}</div> <div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance or 0) }}</div>
{% if year_stats.distances_by_transport_type %}
{% for transport_type, distance in year_stats.distances_by_transport_type.items() %} {% for transport_type, distance in year_stats.distances_by_transport_type.items() %}
<div> <div>
{{ transport_type | title }} {{ transport_type | title }}
distance: {{format_distance(distance) }} distance: {{format_distance(distance) }}
</div> </div>
{% endfor %} {% endfor %}
{% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% endblock %} {% endblock %}