Hide GB from countries visited on trip stats

This commit is contained in:
Edward Betts 2024-07-10 19:28:07 +01:00
parent b38ec99628
commit efae1b9b14

View file

@ -392,13 +392,17 @@ def calculate_yearly_stats(trips: list[Trip]) -> dict[int, StrDict]:
yearly_stats[year]["total_distance"] = (
yearly_stats[year].get("total_distance", 0) + trip.total_distance()
)
for transport_type, distance in trip.distances_by_transport_type():
yearly_stats[year].setdefault("distances_by_transport_type", {})
yearly_stats[year]["distances_by_transport_type"][transport_type] = (
yearly_stats[year]["distances_by_transport_type"].get(transport_type, 0)
+ distance
)
for country in trip.countries:
if country.alpha_2 == "GB":
continue
yearly_stats[year].setdefault("countries", set())
yearly_stats[year]["countries"].add(country)
for leg in trip.travel: