auto-sync: 2026-04-20 20:10:02
This commit is contained in:
@@ -417,7 +417,7 @@ def schedule_data():
|
||||
flight_number, airline_name, airport_iata, direction,
|
||||
origin_iata, destination_iata,
|
||||
scheduled_at, actual_at, status, icao24,
|
||||
flight_date
|
||||
flight_date, duration_min
|
||||
FROM fr24_ext.schedule
|
||||
WHERE {where}
|
||||
ORDER BY scheduled_at DESC
|
||||
@@ -444,6 +444,7 @@ def schedule_data():
|
||||
"scheduled_at": sched.isoformat() if sched else None,
|
||||
"actual_at": actual.isoformat() if actual else None,
|
||||
"delay_min": delay_min,
|
||||
"duration_min": r["duration_min"],
|
||||
"status": r["status"],
|
||||
"icao24": r["icao24"],
|
||||
})
|
||||
@@ -464,7 +465,7 @@ def schedule_export():
|
||||
SELECT
|
||||
flight_date, flight_number, airline_name, airport_iata, direction,
|
||||
origin_iata, destination_iata,
|
||||
scheduled_at, actual_at, status, icao24
|
||||
scheduled_at, actual_at, status, icao24, duration_min
|
||||
FROM fr24_ext.schedule
|
||||
WHERE {where}
|
||||
ORDER BY scheduled_at DESC
|
||||
@@ -478,7 +479,7 @@ def schedule_export():
|
||||
writer.writerow([
|
||||
"Date", "Flight", "Airline", "Airport", "Direction",
|
||||
"Origin", "Destination", "Scheduled", "Actual",
|
||||
"Delay (min)", "Status", "ICAO24",
|
||||
"Delay (min)", "Duration (min)", "Status", "ICAO24",
|
||||
])
|
||||
for r in rows:
|
||||
sched = r["scheduled_at"]
|
||||
@@ -498,6 +499,7 @@ def schedule_export():
|
||||
sched.isoformat() if sched else "",
|
||||
actual.isoformat() if actual else "",
|
||||
delay,
|
||||
r["duration_min"] or "",
|
||||
r["status"] or "",
|
||||
r["icao24"] or "",
|
||||
])
|
||||
|
||||
@@ -123,6 +123,7 @@ def _parse_item(item: Dict, direction: str) -> Optional[Dict]:
|
||||
"origin_iata": origin_iata,
|
||||
"destination_iata": destination_iata,
|
||||
"aircraft_type": thread.get("vehicle"),
|
||||
"duration_min": thread.get("duration"),
|
||||
"scheduled_at": scheduled_at,
|
||||
"direction": direction,
|
||||
"status": "scheduled",
|
||||
@@ -157,17 +158,18 @@ def upsert_flights(conn, flights: List[Dict], airport_iata: str, flight_date: da
|
||||
INSERT INTO fr24_ext.schedule
|
||||
(flight_date, airport_iata, direction, flight_number,
|
||||
airline_iata, airline_name, origin_iata, destination_iata,
|
||||
aircraft_type, scheduled_at, status, source)
|
||||
aircraft_type, duration_min, scheduled_at, status, source)
|
||||
VALUES
|
||||
(%(flight_date)s, %(airport_iata)s, %(direction)s, %(flight_number)s,
|
||||
%(airline_iata)s, %(airline_name)s, %(origin_iata)s, %(destination_iata)s,
|
||||
%(aircraft_type)s, %(scheduled_at)s, %(status)s, %(source)s)
|
||||
%(aircraft_type)s, %(duration_min)s, %(scheduled_at)s, %(status)s, %(source)s)
|
||||
ON CONFLICT (flight_number, airport_iata, scheduled_at, direction)
|
||||
DO UPDATE SET
|
||||
airline_name = EXCLUDED.airline_name,
|
||||
origin_iata = COALESCE(EXCLUDED.origin_iata, fr24_ext.schedule.origin_iata),
|
||||
destination_iata = COALESCE(EXCLUDED.destination_iata, fr24_ext.schedule.destination_iata),
|
||||
aircraft_type = COALESCE(EXCLUDED.aircraft_type, fr24_ext.schedule.aircraft_type),
|
||||
duration_min = COALESCE(EXCLUDED.duration_min, fr24_ext.schedule.duration_min),
|
||||
status = EXCLUDED.status,
|
||||
fetched_at = now()
|
||||
""",
|
||||
@@ -181,6 +183,7 @@ def upsert_flights(conn, flights: List[Dict], airport_iata: str, flight_date: da
|
||||
"origin_iata": flight.get("origin_iata"),
|
||||
"destination_iata": flight.get("destination_iata"),
|
||||
"aircraft_type": flight.get("aircraft_type"),
|
||||
"duration_min": flight.get("duration_min"),
|
||||
"scheduled_at": flight["scheduled_at"],
|
||||
"status": flight.get("status", "scheduled"),
|
||||
"source": flight["source"],
|
||||
|
||||
Reference in New Issue
Block a user