From 591bb316b9a1958fbb54858352bae5e7ca6463d0 Mon Sep 17 00:00:00 2001 From: Stream Date: Tue, 21 Apr 2026 17:20:01 +0300 Subject: [PATCH] auto-sync: 2026-04-21 17:20:01 --- tasks/flightradar24/ingest/mart/build_mart.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tasks/flightradar24/ingest/mart/build_mart.py b/tasks/flightradar24/ingest/mart/build_mart.py index f682cb9..200a586 100644 --- a/tasks/flightradar24/ingest/mart/build_mart.py +++ b/tasks/flightradar24/ingest/mart/build_mart.py @@ -204,7 +204,7 @@ def find_fr24_track(conn, flight_number: str, flight_date: date, if not rows: return None - # Route match REQUIRED for numeric-only matching (avoids e.g. DP6807 → SU6807) + # Full route match (preferred) if origin_iata and destination_iata: for row in rows: orig_iata = ICAO_TO_IATA.get(row[2]) @@ -212,7 +212,14 @@ def find_fr24_track(conn, flight_number: str, flight_date: date, if orig_iata == origin_iata and dest_iata == destination_iata: return (row[0], row[1]) - # No route match — do not return a wrong track + # Soft match: only origin known (destination_iata is NULL in schedule) + if origin_iata and not destination_iata: + for row in rows: + orig_iata = ICAO_TO_IATA.get(row[2]) + if orig_iata == origin_iata: + return (row[0], row[1]) + + # No match return None @@ -265,7 +272,7 @@ def find_fa_track(conn, flight_number: str, flight_date: date, if not rows: return None - # Route match REQUIRED for numeric-only matching + # Full route match (preferred) if origin_iata and destination_iata: for row in rows: orig_iata = ICAO_TO_IATA.get(row[2]) @@ -273,7 +280,14 @@ def find_fa_track(conn, flight_number: str, flight_date: date, if orig_iata == origin_iata and dest_iata == destination_iata: return (row[0], row[1]) - # No route match — do not return a wrong track + # Soft match: only origin known (destination_iata is NULL in schedule) + if origin_iata and not destination_iata: + for row in rows: + orig_iata = ICAO_TO_IATA.get(row[2]) + if orig_iata == origin_iata: + return (row[0], row[1]) + + # No match return None