Show the number of new countries visited each year in parentheses next to the total country count. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			90 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{% extends "base.html" %}
 | 
						|
 | 
						|
{% from "macros.html" import format_distance with context %}
 | 
						|
 | 
						|
{% set heading = "Trip statistics" %}
 | 
						|
 | 
						|
{% block title %}{{ heading }} - Edward Betts{% endblock %}
 | 
						|
 | 
						|
{% block content %}
 | 
						|
<div class="container-fluid">
 | 
						|
  <h1>Trip statistics</h1>
 | 
						|
  <div>Trips: {{ count }}</div>
 | 
						|
  <div>Conferences: {{ conferences }}</div>
 | 
						|
  <div>Total distance: {{ format_distance(total_distance) }}</div>
 | 
						|
 | 
						|
  {% for transport_type, distance in distances_by_transport_type %}
 | 
						|
    <div>
 | 
						|
      {{ transport_type | title }}
 | 
						|
      distance: {{format_distance(distance) }}
 | 
						|
    </div>
 | 
						|
  {% endfor %}
 | 
						|
 | 
						|
  {% for year, year_stats in yearly_stats | dictsort %}
 | 
						|
    {% set countries = year_stats.countries | sort(attribute="name") %}
 | 
						|
    <h4>{{ year }}</h4>
 | 
						|
    <div>Trips in {{ year }}: {{ year_stats.count }}</div>
 | 
						|
    <div>Conferences in {{ year }}: {{ year_stats.conferences }}</div>
 | 
						|
    <div>{{ countries | count }} countries visited in {{ year }}:
 | 
						|
      {% set new_countries = [] %}
 | 
						|
      {% for c in countries %}
 | 
						|
        {% if c.alpha_2 not in previously_visited %}
 | 
						|
          {% set _ = new_countries.append(c) %}
 | 
						|
        {% endif %}
 | 
						|
      {% endfor %}
 | 
						|
      {% if new_countries %}
 | 
						|
        ({{ new_countries | count }} new)
 | 
						|
      {% endif %}
 | 
						|
      {% for c in countries %}
 | 
						|
        <span class="text-nowrap border border-2 px-2 my-3 mx-1">
 | 
						|
          {{ c.flag }} {{ c.name }} ({{ c.alpha_2 }})
 | 
						|
          {% if c.alpha_2 not in previously_visited %}
 | 
						|
            <span class="badge text-bg-info">new</span>
 | 
						|
          {% endif %}
 | 
						|
        </span>
 | 
						|
      {% endfor %}
 | 
						|
      </div>
 | 
						|
    <div>
 | 
						|
      Flight segments in {{ year }}: {{ year_stats.flight_count or 0 }}
 | 
						|
      {% if year_stats.airlines %}
 | 
						|
      [ by airline:
 | 
						|
        {% for airline, count in year_stats.airlines.most_common() %}
 | 
						|
          {{ airline }}: {{ count }}{% if not loop.last %},{% endif %}
 | 
						|
        {% endfor %} ]
 | 
						|
      {% endif %}
 | 
						|
    </div>
 | 
						|
    {% if year_stats.co2_kg %}
 | 
						|
      <div>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 %}
 | 
						|
      </div>
 | 
						|
      {% if year_stats.co2_by_transport_type %}
 | 
						|
        {% for transport_type, co2_kg in year_stats.co2_by_transport_type.items() %}
 | 
						|
          <div style="margin-left: 20px;">
 | 
						|
            {{ transport_type | title }} CO₂: 
 | 
						|
            {% if co2_kg >= 1000 %}
 | 
						|
              {{ "{:,.2f}".format(co2_kg / 1000.0) }} tonnes
 | 
						|
            {% else %}
 | 
						|
              {{ "{:,.0f}".format(co2_kg) }} kg
 | 
						|
            {% endif %}
 | 
						|
          </div>
 | 
						|
        {% endfor %}
 | 
						|
      {% endif %}
 | 
						|
    {% 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 %}
 | 
						|
    {% for transport_type, distance in year_stats.distances_by_transport_type.items() %}
 | 
						|
      <div>
 | 
						|
        {{ transport_type | title }}
 | 
						|
        distance: {{format_distance(distance) }}
 | 
						|
      </div>
 | 
						|
    {% endfor %}
 | 
						|
    {% endif %}
 | 
						|
  {% endfor %}
 | 
						|
</div>
 | 
						|
{% endblock %}
 |