parent
efae1b9b14
commit
17eca6a95a
|
@ -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()
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<div class="container-fluid">
|
||||
<h1>Trip statistics</h1>
|
||||
<div>Trips: {{ count }}</div>
|
||||
<div>Conferences: {{ conferences }}</div>
|
||||
<div>Total distance: {{ format_distance(total_distance) }}</div>
|
||||
|
||||
{% for transport_type, distance in distances_by_transport_type %}
|
||||
|
@ -23,6 +24,7 @@
|
|||
{% set countries = year_stats.countries | sort(attribute="name") %}
|
||||
<h4>{{ year }}</h4>
|
||||
<div>Trips in {{ year }}: {{ year_stats.count }}</div>
|
||||
<div>Conferences in {{ year }}: {{ year_stats.conferences }}</div>
|
||||
<div>{{ countries | count }} countries visited in {{ year }}:
|
||||
{% for c in countries %}
|
||||
<span class="text-nowrap">{{ c.flag }} {{ c.name }}</span>
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue