Compare commits
	
		
			2 commits
		
	
	
		
			9a204d8526
			...
			77f0b17b37
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							
							
								
									
								
								 | 
						77f0b17b37 | ||
| 
							
							
								
									
								
								 | 
						f6d715e52a | 
| 
						 | 
				
			
			@ -31,20 +31,24 @@
 | 
			
		|||
      {% endfor %}
 | 
			
		||||
      </div>
 | 
			
		||||
    <div>
 | 
			
		||||
      Flight segments in {{ year }}: {{ year_stats.flight_count }}
 | 
			
		||||
      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 %} ]
 | 
			
		||||
        {% for airline, count in year_stats.airlines.most_common() %}
 | 
			
		||||
          {{ airline }}: {{ count }}{% if not loop.last %},{% endif %}
 | 
			
		||||
        {% endfor %} ]
 | 
			
		||||
      {% endif %}
 | 
			
		||||
    </div>
 | 
			
		||||
    <div>Trains segments in {{ year }}: {{ year_stats.train_count }}</div>
 | 
			
		||||
    <div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}</div>
 | 
			
		||||
    <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 %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,14 +43,20 @@ def check_trips() -> None:
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
def check_flights(airlines: set[str]) -> None:
 | 
			
		||||
    """Check flights."""
 | 
			
		||||
    """Check flights and ensure they are in chronological order."""
 | 
			
		||||
    bookings = agenda.travel.parse_yaml("flights", data_dir)
 | 
			
		||||
 | 
			
		||||
    prev_first_depart = None
 | 
			
		||||
    for booking in bookings:
 | 
			
		||||
        assert all(flight["airline"] in airlines for flight in booking["flights"])
 | 
			
		||||
 | 
			
		||||
    for booking in bookings:
 | 
			
		||||
        check_currency(booking)
 | 
			
		||||
 | 
			
		||||
        if prev_first_depart:
 | 
			
		||||
            assert (
 | 
			
		||||
                booking["flights"][0]["depart"] > prev_first_depart
 | 
			
		||||
            ), "Bookings are not in chronological order by first flight's departure."
 | 
			
		||||
        prev_first_depart = booking["flights"][0]["depart"]
 | 
			
		||||
 | 
			
		||||
    print(len(bookings), "flights")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue