Show CO₂ on stats page.
This commit is contained in:
parent
f6fba93a54
commit
24c3242189
|
@ -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())
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
{% endfor %} ]
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if year_stats.co2_kg %}
|
||||
<div>Flight CO₂: {{ "{:,.1f}".format(year_stats.co2_kg / 1000.0) }} tonnes</div>
|
||||
{% endif %}
|
||||
<div>Trains segments in {{ year }}: {{ year_stats.train_count or 0 }}</div>
|
||||
<div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance or 0) }}</div>
|
||||
{% if year_stats.distances_by_transport_type %}
|
||||
|
|
Loading…
Reference in a new issue