diff --git a/templates/trip/stats.html b/templates/trip/stats.html index 4b535d5..bbfa044 100644 --- a/templates/trip/stats.html +++ b/templates/trip/stats.html @@ -20,8 +20,14 @@ {% endfor %} {% for year, year_stats in yearly_stats | dictsort %} + {% set countries = year_stats.countries | sort(attribute="name") %}

{{ year }}

Trips in {{ year }}: {{ year_stats.count }}
+
{{ countries | count }} countries visited in {{ year }}: + {% for c in countries %} + {{ c.flag }} {{ c.name }} + {% endfor %} +
Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}
{% for transport_type, distance in year_stats.distances_by_transport_type.items() %}
diff --git a/web_view.py b/web_view.py index 5c39a50..76440f7 100755 --- a/web_view.py +++ b/web_view.py @@ -544,6 +544,9 @@ def calculate_yearly_stats(trips: list[Trip]) -> dict[int, StrDict]: yearly_stats[year]["distances_by_transport_type"].get(transport_type, 0) + distance ) + for country in trip.countries: + yearly_stats[year].setdefault("countries", set()) + yearly_stats[year]["countries"].add(country) return dict(yearly_stats)