Move trip new-country filtering into stats
This commit is contained in:
parent
ddfa77b152
commit
f22772d12d
5 changed files with 27 additions and 15 deletions
10
web_view.py
10
web_view.py
|
|
@ -461,7 +461,9 @@ def accommodation_list() -> str:
|
|||
items = travel.parse_yaml("accommodation", data_dir)
|
||||
|
||||
# Create a dictionary to hold stats for each year
|
||||
year_stats = defaultdict(lambda: {"total_nights": 0, "nights_abroad": 0})
|
||||
year_stats: defaultdict[int, dict[str, int]] = defaultdict(
|
||||
lambda: {"total_nights": 0, "nights_abroad": 0}
|
||||
)
|
||||
|
||||
# Calculate stats for each year
|
||||
for stay in items:
|
||||
|
|
@ -536,7 +538,7 @@ def calc_total_distance(trips: list[Trip]) -> float:
|
|||
|
||||
def calc_total_co2_kg(trips: list[Trip]) -> float:
|
||||
"""Total CO₂ for trips."""
|
||||
return sum(item.total_co2_kg() for item in trips)
|
||||
return sum(item.total_co2_kg() or 0.0 for item in trips)
|
||||
|
||||
|
||||
def sum_distances_by_transport_type(trips: list[Trip]) -> list[tuple[str, float]]:
|
||||
|
|
@ -806,7 +808,9 @@ def trip_stats() -> str:
|
|||
|
||||
conferences = sum(len(item.conferences) for item in trip_list)
|
||||
|
||||
yearly_stats = agenda.stats.calculate_yearly_stats(trip_list)
|
||||
yearly_stats = agenda.stats.calculate_yearly_stats(
|
||||
trip_list, app.config.get("PREVIOUSLY_VISITED")
|
||||
)
|
||||
|
||||
return flask.render_template(
|
||||
"trip/stats.html",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue