diff --git a/agenda/trip.py b/agenda/trip.py index f5557ea..850da77 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -388,6 +388,11 @@ def calculate_yearly_stats(trips: list[Trip]) -> dict[int, StrDict]: dist = trip.total_distance() yearly_stats[year].setdefault("count", 0) yearly_stats[year]["count"] += 1 + + for c in trip.conferences: + yearly_stats[c["start"].year].setdefault("conferences", 0) + yearly_stats[c["start"].year]["conferences"] += 1 + if dist: yearly_stats[year]["total_distance"] = ( yearly_stats[year].get("total_distance", 0) + trip.total_distance() diff --git a/templates/trip/stats.html b/templates/trip/stats.html index 6fe8a18..d6f379e 100644 --- a/templates/trip/stats.html +++ b/templates/trip/stats.html @@ -10,6 +10,7 @@

Trip statistics

Trips: {{ count }}
+
Conferences: {{ conferences }}
Total distance: {{ format_distance(total_distance) }}
{% for transport_type, distance in distances_by_transport_type %} @@ -23,6 +24,7 @@ {% set countries = year_stats.countries | sort(attribute="name") %}

{{ year }}

Trips in {{ year }}: {{ year_stats.count }}
+
Conferences in {{ year }}: {{ year_stats.conferences }}
{{ countries | count }} countries visited in {{ year }}: {% for c in countries %} {{ c.flag }} {{ c.name }} diff --git a/web_view.py b/web_view.py index eed6048..4e95567 100755 --- a/web_view.py +++ b/web_view.py @@ -590,6 +590,7 @@ def trip_stats() -> str: today = date.today() past = [item for item in trip_list if (item.end or item.start) < today] + conferences = sum(len(item.conferences) for item in past) yearly_stats = agenda.trip.calculate_yearly_stats(past) @@ -599,6 +600,7 @@ def trip_stats() -> str: total_distance=calc_total_distance(past), distances_by_transport_type=sum_distances_by_transport_type(past), yearly_stats=yearly_stats, + conferences=conferences, )