actual times via AeroDataBox + FlightAware runway fallback
This commit is contained in:
+21
-1
@@ -98,7 +98,10 @@ def build_save_payload(row: dict, existing_id: int | None) -> dict:
|
||||
payload = {
|
||||
"from": row["from_iata"],
|
||||
"to": row["to_iata"],
|
||||
"departure": f"{flight_date_str}T00:00:00.000+00:00",
|
||||
# Falls back to the bare date (day precision, no time) exactly like
|
||||
# before if AeroDataBox never returned a gate-actual time - e.g. no
|
||||
# AERODATABOX_API_KEY configured, or the lookup came up empty.
|
||||
"departure": row.get("gate_departure_actual") or f"{flight_date_str}T00:00:00.000+00:00",
|
||||
"datePrecision": "day",
|
||||
"flightNumber": flight_number or None,
|
||||
"airline": row.get("operating_carrier_icao"),
|
||||
@@ -117,6 +120,23 @@ def build_save_payload(row: dict, existing_id: int | None) -> dict:
|
||||
],
|
||||
}
|
||||
|
||||
# Scheduled/actual gate times from AeroDataBox (scheduler._fetch_gate_times),
|
||||
# and actual takeoff/landing derived from the FlightAware track's first/last
|
||||
# timestamp (scheduler.process_one_flight). Any of these can be missing -
|
||||
# e.g. no AERODATABOX_API_KEY set, the lookup came up empty, or no track was
|
||||
# found - in which case the field is simply omitted and AirTrail's own
|
||||
# manual Search remains the fallback, same as before this change.
|
||||
if row.get("gate_departure_scheduled"):
|
||||
payload["departureScheduled"] = row["gate_departure_scheduled"]
|
||||
if row.get("gate_arrival_scheduled"):
|
||||
payload["arrivalScheduled"] = row["gate_arrival_scheduled"]
|
||||
if row.get("gate_arrival_actual"):
|
||||
payload["arrival"] = row["gate_arrival_actual"]
|
||||
if row.get("takeoff_actual"):
|
||||
payload["takeoffActual"] = row["takeoff_actual"]
|
||||
if row.get("landing_actual"):
|
||||
payload["landingActual"] = row["landing_actual"]
|
||||
|
||||
coordinates = row.get("track_coordinates")
|
||||
if coordinates:
|
||||
times = row.get("track_times")
|
||||
|
||||
Reference in New Issue
Block a user