diff --git a/agenda/types.py b/agenda/types.py index 4f9d273..37fbe06 100644 --- a/agenda/types.py +++ b/agenda/types.py @@ -204,10 +204,6 @@ class Trip: else None ) - def total_co2_kg(self) -> float | None: - """Total CO₂ for trip.""" - return sum(float(t.get("co2_kg", 0)) for t in self.travel) - @property def flights(self) -> list[StrDict]: """Flights.""" diff --git a/templates/macros.html b/templates/macros.html index 9a7b068..a7b67a7 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -113,7 +113,7 @@ {% endif %} {% endif %} - {% for i in range(9) %} + {% for i in range(8) %}
{% endfor %} @@ -143,7 +143,6 @@ {{ "{:,.0f} km / {:,.0f} miles".format(item.distance, item.distance / 1.60934) }} {% endif %} -
{{ "{:,.1f}".format(item.co2_kg) }} kg
{% endfor %} {% endmacro %} @@ -307,7 +306,6 @@ {% macro trip_item(trip) %} {% set distances_by_transport_type = trip.distances_by_transport_type() %} {% set total_distance = trip.total_distance() %} - {% set total_co2_kg = trip.total_co2_kg() %} {% set end = trip.end %}

@@ -337,7 +335,6 @@

{% endif %} - {% if distances_by_transport_type %} {% for transport_type, distance in distances_by_transport_type %}
@@ -347,10 +344,6 @@ {% endfor %} {% endif %} - {% if total_co2_kg %} -
Total CO₂: {{ "{:,.1f}".format(total_co2_kg) }} kg
- {% endif %} - {{ conference_list(trip) }} {% for day, elements in trip.elements_grouped_by_day() %} @@ -388,7 +381,6 @@ duration: {{ e.detail.duration }} {% endif %} {#
{{ e.detail | pprint }}
#} - CO₂: {{ "{:,.1f}".format(e.detail.co2_kg) }} kg {% endif %} {% if e.detail.distance %} distance: {{ format_distance(e.detail.distance) }} diff --git a/templates/travel.html b/templates/travel.html index ebb937b..06d1d4e 100644 --- a/templates/travel.html +++ b/templates/travel.html @@ -3,7 +3,7 @@ {% block title %}Travel - Edward Betts{% endblock %} -{% set flight_column_count = 11 %} +{% set flight_column_count = 10 %} {% set column_count = 10 %} {% block style %} @@ -47,7 +47,6 @@
flight
tracking
distance
-
CO₂ (kg)
{% for item in flights %} {{ flight_booking_row(item) }} diff --git a/templates/trip/list.html b/templates/trip/list.html index 2e9fe5a..afb5c2c 100644 --- a/templates/trip/list.html +++ b/templates/trip/list.html @@ -62,7 +62,6 @@ distance: {{format_distance(distance) }}
{% endfor %} -
Total CO₂: {{ "{:,.1f}".format(total_co2_kg / 1000.0) }} tonnes
{% for trip in items %} {{ trip_item(trip) }} diff --git a/update.py b/update.py index 2c94e6a..30b65a7 100755 --- a/update.py +++ b/update.py @@ -8,7 +8,7 @@ import typing from datetime import date, datetime from time import time -import deepdiff +import deepdiff # type: ignore import flask import requests import yaml diff --git a/web_view.py b/web_view.py index 62222be..70c48dd 100755 --- a/web_view.py +++ b/web_view.py @@ -404,17 +404,13 @@ def calc_total_distance(trips: list[Trip]) -> float: """Total distance for trips.""" total = 0.0 for item in trips: - if dist := item.total_distance(): + dist = item.total_distance() + if dist: total += dist return total -def calc_total_co2_kg(trips: list[Trip]) -> float: - """Total CO₂ for trips.""" - return sum(item.total_co2_kg() for item in trips) - - def sum_distances_by_transport_type(trips: list[Trip]) -> list[tuple[str, float]]: """Sum distances by transport type.""" distances_by_transport_type: defaultdict[str, float] = defaultdict(float) @@ -447,7 +443,6 @@ def trip_past_list() -> str: format_list_with_ampersand=format_list_with_ampersand, fx_rate=agenda.fx.get_rates(app.config), total_distance=calc_total_distance(past), - total_co2_kg=calc_total_co2_kg(past), distances_by_transport_type=sum_distances_by_transport_type(past), ) @@ -480,7 +475,6 @@ def trip_future_list() -> str: format_list_with_ampersand=format_list_with_ampersand, fx_rate=agenda.fx.get_rates(app.config), total_distance=calc_total_distance(current + future), - total_co2_kg=calc_total_co2_kg(current + future), distances_by_transport_type=sum_distances_by_transport_type(current + future), )