From 5c65e4d2eefb040a9e898441ad80fc73b2904542 Mon Sep 17 00:00:00 2001 From: domverse Date: Mon, 2 Mar 2026 21:45:07 +0100 Subject: [PATCH] fix: add BER to airports.py so scans include Berlin Brandenburg OpenFlights dataset predates BER's 2020 opening. The patch already existed in api_server.py for the search UI, but scan_processor.py uses airports.py directly, so Germany scans silently skipped BER. Added _MISSING_AIRPORTS to airports.py, patched both get_airports_for_country() and _all_airports_by_iata() to inject the extras, making BER available to scans and lookups. Co-Authored-By: Claude Sonnet 4.6 --- flight-comparator/airports.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/flight-comparator/airports.py b/flight-comparator/airports.py index 08b785c..6b03c57 100644 --- a/flight-comparator/airports.py +++ b/flight-comparator/airports.py @@ -69,6 +69,13 @@ COUNTRY_NAME_TO_ISO = { } +# Airports missing from the OpenFlights dataset (opened or renamed after dataset was last updated). +# Keyed by ISO country code; dicts match the airports_by_country.json schema (iata/name/city/icao). +_MISSING_AIRPORTS: dict[str, list[dict]] = { + 'DE': [{'iata': 'BER', 'name': 'Berlin Brandenburg Airport', 'city': 'Berlin', 'icao': 'EDDB'}], +} + + def country_name_to_iso_code(country_name: str) -> Optional[str]: """ Convert country name to ISO 2-letter code. @@ -197,7 +204,12 @@ def get_airports_for_country(country_code: str) -> list[dict]: f"Available codes (sample): {', '.join(available)}..." ) - return airports_by_country[country_code] + result = list(airports_by_country[country_code]) + existing_iatas = {a['iata'] for a in result} + for extra in _MISSING_AIRPORTS.get(country_code, []): + if extra['iata'] not in existing_iatas: + result.append(extra) + return result def resolve_airport_list(country: Optional[str], from_airports: Optional[str]) -> list[dict]: @@ -233,11 +245,16 @@ def _all_airports_by_iata() -> dict: download_and_build_airport_data() with open(AIRPORTS_JSON_PATH, 'r', encoding='utf-8') as f: airports_by_country = json.load(f) - return { + result = { a['iata']: a for airports in airports_by_country.values() for a in airports } + for extras in _MISSING_AIRPORTS.values(): + for extra in extras: + if extra['iata'] not in result: + result[extra['iata']] = extra + return result def lookup_airport(iata: str) -> dict | None: