diff --git a/agenda/stats.py b/agenda/stats.py index d9bdc51..c98cce9 100644 --- a/agenda/stats.py +++ b/agenda/stats.py @@ -9,6 +9,9 @@ from agenda.types import StrDict, Trip def travel_legs(trip: Trip, stats: StrDict) -> None: """Calculate stats for travel legs.""" for leg in trip.travel: + stats.setdefault("co2_kg", 0) + if "co2_kg" in leg: + stats["co2_kg"] += leg["co2_kg"] if leg["type"] == "flight": stats.setdefault("flight_count", 0) stats.setdefault("airlines", Counter()) diff --git a/templates/trip/stats.html b/templates/trip/stats.html index 8644aff..b463fd0 100644 --- a/templates/trip/stats.html +++ b/templates/trip/stats.html @@ -44,6 +44,9 @@ {% endfor %} ] {% endif %} + {% if year_stats.co2_kg %} +