auto-sync: 2026-04-21 13:20:01
This commit is contained in:
@@ -153,7 +153,7 @@ def find_fa_track(conn, flight_number: str, flight_date: date,
|
||||
# Exact match on ident_iata
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT id, aircraft_type, origin_iata, destination_iata
|
||||
SELECT id, aircraft_type, origin_icao, destination_icao
|
||||
FROM fr24_ext.flight_tracks_fa
|
||||
WHERE ident_iata = %s AND flight_date = %s
|
||||
ORDER BY fetched_at DESC
|
||||
@@ -166,16 +166,19 @@ def find_fa_track(conn, flight_number: str, flight_date: date,
|
||||
return (rows[0][0], rows[0][1])
|
||||
if origin_iata and destination_iata:
|
||||
for row in rows:
|
||||
if row[2] == origin_iata and row[3] == destination_iata:
|
||||
orig_iata = ICAO_TO_IATA.get(row[2])
|
||||
dest_iata = ICAO_TO_IATA.get(row[3])
|
||||
if orig_iata == origin_iata and dest_iata == destination_iata:
|
||||
return (row[0], row[1])
|
||||
return (rows[0][0], rows[0][1])
|
||||
|
||||
# Try by numeric ident + route
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT id, aircraft_type, origin_iata, destination_iata
|
||||
SELECT id, aircraft_type, origin_icao, destination_icao
|
||||
FROM fr24_ext.flight_tracks_fa
|
||||
WHERE ident_iata ~ (%s || '$') AND flight_date = %s
|
||||
WHERE regexp_replace(ident_iata, '[^0-9]', '', 'g') = %s
|
||||
AND flight_date = %s
|
||||
ORDER BY fetched_at DESC
|
||||
""",
|
||||
(fnum, flight_date),
|
||||
@@ -186,7 +189,9 @@ def find_fa_track(conn, flight_number: str, flight_date: date,
|
||||
|
||||
if origin_iata and destination_iata:
|
||||
for row in rows:
|
||||
if row[2] == origin_iata and row[3] == destination_iata:
|
||||
orig_iata = ICAO_TO_IATA.get(row[2])
|
||||
dest_iata = ICAO_TO_IATA.get(row[3])
|
||||
if orig_iata == origin_iata and dest_iata == destination_iata:
|
||||
return (row[0], row[1])
|
||||
|
||||
return (rows[0][0], rows[0][1])
|
||||
|
||||
Reference in New Issue
Block a user