diff --git a/templates/trip/stats.html b/templates/trip/stats.html index f912177..38bf51b 100644 --- a/templates/trip/stats.html +++ b/templates/trip/stats.html @@ -6,128 +6,116 @@ {% block title %}{{ heading }} - Edward Betts{% endblock %} +{% macro stat_list(id, label, counter, show_top=5) %} +
+ {{ label }}: {{ counter | count }} + {% if counter | count > 0 %} + +
+
+ {% for item, count in counter.most_common() %} + {{ item }} {{ count }} + {% endfor %} +
+
+ {% endif %} +
+{% endmacro %} + {% block content %}

Trip statistics

-
Trips: {{ count }}
-
Conferences: {{ conferences }}
-
Total distance: {{ format_distance(total_distance) }}
- {% for transport_type, distance in distances_by_transport_type %} -
- {{ transport_type | title }} - distance: {{format_distance(distance) }} +
+
Overall Summary
+
+
+
+
Trips: {{ count }}
+
Conferences: {{ conferences }}
+
Total distance: {{ format_distance(total_distance) }}
+ {% for transport_type, distance in distances_by_transport_type %} +
{{ transport_type | title }}: {{ format_distance(distance) }}
+ {% endfor %} +
+
+
Flight segments: {{ overall_stats.flight_count }}
+
Train segments: {{ overall_stats.train_count }}
+
+
+ +
+ + {{ stat_list("overall-airlines", "Airlines", overall_stats.airlines) }} + {{ stat_list("overall-airports", "Airports", overall_stats.airports) }} + {{ stat_list("overall-stations", "Stations", overall_stats.stations) }}
- {% endfor %} - -
- Flight segments: {{ overall_stats.flight_count }} - {% if overall_stats.airlines %} - ({{ overall_stats.airlines | count }} airlines) - [ by airline: - {% for airline, count in overall_stats.airlines.most_common() %} - {{ airline }}: {{ count }}{% if not loop.last %},{% endif %} - {% endfor %} ] - {% endif %}
- {% if overall_stats.airports %} -
- Airports used: {{ overall_stats.airports | count }} - [ by airport: - {% for airport, count in overall_stats.airports.most_common() %} - {{ airport }}: {{ count }}{% if not loop.last %},{% endif %} - {% endfor %} ] -
- {% endif %} -
Train segments: {{ overall_stats.train_count }}
- {% if overall_stats.stations %} -
- Stations used: {{ overall_stats.stations | count }} - [ by station: - {% for station, count in overall_stats.stations.most_common() %} - {{ station }}: {{ count }}{% if not loop.last %},{% endif %} - {% endfor %} ] -
- {% endif %} {% for year, year_stats in yearly_stats | dictsort(reverse=True) %} {% set countries = year_stats.countries | default([]) | sort(attribute="name") %} {% set new_countries = year_stats.new_countries | default([]) %} -

{{ year }}

-
Trips in {{ year }}: {{ year_stats.count }}
-
Conferences in {{ year }}: {{ year_stats.conferences }}
-
{{ countries | count }} countries visited in {{ year }}: - {% if new_countries %} - ({{ new_countries | count }} new) - {% endif %} - {% for c in countries %} - - {{ c.flag }} {{ c.name }} ({{ c.alpha_2 }}) - {% if c in new_countries %} - new - {% endif %} - - {% endfor %} + +
+
+ {{ year }} + {{ year_stats.count }} trips
-
- Flight segments in {{ year }}: {{ year_stats.flight_count or 0 }} - {% if year_stats.airlines %} - ({{ year_stats.airlines | count }} airlines) - [ by airline: - {% for airline, count in year_stats.airlines.most_common() %} - {{ airline }}: {{ count }}{% if not loop.last %},{% endif %} - {% endfor %} ] - {% endif %} -
- {% if year_stats.airports %} -
- Airports used in {{ year }}: {{ year_stats.airports | count }} - [ by airport: - {% for airport, count in year_stats.airports.most_common() %} - {{ airport }}: {{ count }}{% if not loop.last %},{% endif %} - {% endfor %} ] -
- {% endif %} - {% if year_stats.co2_kg %} -
Total CO₂: - {% if year_stats.co2_kg >= 1000 %} - {{ "{:,.2f}".format(year_stats.co2_kg / 1000.0) }} tonnes - {% else %} - {{ "{:,.0f}".format(year_stats.co2_kg) }} kg - {% endif %} -
- {% if year_stats.co2_by_transport_type %} - {% for transport_type, co2_kg in year_stats.co2_by_transport_type.items() %} -
- {{ transport_type | title }} CO₂: - {% if co2_kg >= 1000 %} - {{ "{:,.2f}".format(co2_kg / 1000.0) }} tonnes - {% else %} - {{ "{:,.0f}".format(co2_kg) }} kg +
+
+
+
Trips: {{ year_stats.count }}
+
Conferences: {{ year_stats.conferences }}
+
Distance: {{ format_distance(year_stats.total_distance or 0) }}
+ {% if year_stats.distances_by_transport_type %} + {% for transport_type, distance in year_stats.distances_by_transport_type.items() %} +
{{ transport_type | title }}: {{ format_distance(distance) }}
+ {% endfor %} {% endif %}
- {% endfor %} - {% endif %} - {% endif %} -
Trains segments in {{ year }}: {{ year_stats.train_count or 0 }}
- {% if year_stats.stations %} -
- Stations used in {{ year }}: {{ year_stats.stations | count }} - [ by station: - {% for station, count in year_stats.stations.most_common() %} - {{ station }}: {{ count }}{% if not loop.last %},{% endif %} - {% endfor %} ] -
- {% endif %} -
Total distance in {{ year}}: {{ format_distance(year_stats.total_distance or 0) }}
- {% if year_stats.distances_by_transport_type %} - {% for transport_type, distance in year_stats.distances_by_transport_type.items() %} -
- {{ transport_type | title }} - distance: {{format_distance(distance) }} +
+
Flight segments: {{ year_stats.flight_count or 0 }}
+
Train segments: {{ year_stats.train_count or 0 }}
+ {% if year_stats.co2_kg %} +
CO₂: + {% if year_stats.co2_kg >= 1000 %} + {{ "{:,.2f}".format(year_stats.co2_kg / 1000.0) }} tonnes + {% else %} + {{ "{:,.0f}".format(year_stats.co2_kg) }} kg + {% endif %} +
+ {% endif %} +
+
+ +
+ Countries: {{ countries | count }} + {% if new_countries %}({{ new_countries | count }} new){% endif %} +
+ {% for c in countries %} + + {{ c.flag }} {{ c.name }} + {% if c in new_countries %} + new + {% endif %} + + {% endfor %} +
+
+ + {% if year_stats.airlines %} + {{ stat_list("airlines-" ~ year, "Airlines", year_stats.airlines) }} + {% endif %} + {% if year_stats.airports %} + {{ stat_list("airports-" ~ year, "Airports", year_stats.airports) }} + {% endif %} + {% if year_stats.stations %} + {{ stat_list("stations-" ~ year, "Stations", year_stats.stations) }} + {% endif %}
- {% endfor %} - {% endif %} +
{% endfor %}
{% endblock %}