parent
1e14a99419
commit
d5bf004912
|
@ -20,8 +20,14 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for year, year_stats in yearly_stats | dictsort %}
|
{% for year, year_stats in yearly_stats | dictsort %}
|
||||||
|
{% set countries = year_stats.countries | sort(attribute="name") %}
|
||||||
<h4>{{ year }}</h4>
|
<h4>{{ year }}</h4>
|
||||||
<div>Trips in {{ year }}: {{ year_stats.count }}</div>
|
<div>Trips in {{ year }}: {{ year_stats.count }}</div>
|
||||||
|
<div>{{ countries | count }} countries visited in {{ year }}:
|
||||||
|
{% for c in countries %}
|
||||||
|
{{ c.flag }} {{ c.name }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
<div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}</div>
|
<div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}</div>
|
||||||
{% 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>
|
||||||
|
|
|
@ -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)
|
yearly_stats[year]["distances_by_transport_type"].get(transport_type, 0)
|
||||||
+ distance
|
+ distance
|
||||||
)
|
)
|
||||||
|
for country in trip.countries:
|
||||||
|
yearly_stats[year].setdefault("countries", set())
|
||||||
|
yearly_stats[year]["countries"].add(country)
|
||||||
return dict(yearly_stats)
|
return dict(yearly_stats)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue