parent
d5bf004912
commit
40578196bc
2 changed files with 9 additions and 0 deletions
|
|
@ -547,6 +547,13 @@ def calculate_yearly_stats(trips: list[Trip]) -> dict[int, StrDict]:
|
|||
for country in trip.countries:
|
||||
yearly_stats[year].setdefault("countries", set())
|
||||
yearly_stats[year]["countries"].add(country)
|
||||
for leg in trip.travel:
|
||||
if leg["type"] == "flight":
|
||||
yearly_stats[year].setdefault("flight_count", 0)
|
||||
yearly_stats[year]["flight_count"] += 1
|
||||
if leg["type"] == "train":
|
||||
yearly_stats[year].setdefault("train_count", 0)
|
||||
yearly_stats[year]["train_count"] += 1
|
||||
return dict(yearly_stats)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue