auto-sync: 2026-04-21 01:40:01
This commit is contained in:
@@ -468,7 +468,7 @@ def schedule_data():
|
||||
flight_number, airline_name, airport_iata, direction,
|
||||
origin_iata, destination_iata,
|
||||
scheduled_at, actual_at, status, icao24,
|
||||
flight_date, duration_min
|
||||
flight_date, duration_min, thread_title
|
||||
FROM fr24_ext.schedule
|
||||
WHERE {where}
|
||||
ORDER BY scheduled_at DESC
|
||||
@@ -494,6 +494,7 @@ def schedule_data():
|
||||
"destination": _city(r["destination_iata"]) or r["destination_iata"] or "",
|
||||
"origin_iata": r["origin_iata"] or "",
|
||||
"destination_iata": r["destination_iata"] or "",
|
||||
"thread_title": r["thread_title"] or "",
|
||||
"scheduled_at": sched.isoformat() if sched else None,
|
||||
"actual_at": actual.isoformat() if actual else None,
|
||||
"delay_min": delay_min,
|
||||
|
||||
@@ -182,22 +182,18 @@ function exportCsv() {
|
||||
// ── helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function routeStr(f) {
|
||||
// Prefer thread_title from Yandex (most accurate)
|
||||
const tt = f.thread_title || "";
|
||||
if (tt) {
|
||||
// "Москва — Алматы" → for departure show destination, for arrival show origin
|
||||
return tt;
|
||||
}
|
||||
const o = f.origin || "";
|
||||
const d = f.destination || "";
|
||||
const oi = f.origin_iata || "";
|
||||
const di = f.destination_iata || "";
|
||||
function fmt(city, iata) {
|
||||
if (!city && !iata) return "";
|
||||
if (!city) return iata;
|
||||
if (city === iata) return city;
|
||||
return city;
|
||||
}
|
||||
const from = fmt(o, oi);
|
||||
const to = fmt(d, di);
|
||||
if (!from && !to) return "—";
|
||||
if (!from) return `→ ${to}`;
|
||||
if (!to) return `${from} →`;
|
||||
return `${from} → ${to}`;
|
||||
if (!o && !d) return "—";
|
||||
if (!o) return `→ ${d}`;
|
||||
if (!d) return `${o} →`;
|
||||
return `${o} → ${d}`;
|
||||
}
|
||||
|
||||
function statusBadge(status) {
|
||||
|
||||
@@ -238,6 +238,7 @@ def _parse_item(item: Dict, direction: str, airport_iata: str) -> Optional[Dict]
|
||||
"direction": direction,
|
||||
"status": "scheduled",
|
||||
"source": "yandex",
|
||||
"thread_title": title,
|
||||
}
|
||||
|
||||
|
||||
@@ -254,11 +255,11 @@ 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, duration_min, scheduled_at, status, source)
|
||||
aircraft_type, duration_min, scheduled_at, status, source, thread_title)
|
||||
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, %(duration_min)s, %(scheduled_at)s, %(status)s, %(source)s)
|
||||
%(aircraft_type)s, %(duration_min)s, %(scheduled_at)s, %(status)s, %(source)s, %(thread_title)s)
|
||||
ON CONFLICT (flight_number, airport_iata, scheduled_at, direction)
|
||||
DO UPDATE SET
|
||||
airline_name = EXCLUDED.airline_name,
|
||||
@@ -266,6 +267,7 @@ def upsert_flights(conn, flights: List[Dict], airport_iata: str, flight_date: da
|
||||
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),
|
||||
thread_title = COALESCE(EXCLUDED.thread_title, fr24_ext.schedule.thread_title),
|
||||
status = EXCLUDED.status,
|
||||
fetched_at = now()
|
||||
""",
|
||||
@@ -283,6 +285,7 @@ def upsert_flights(conn, flights: List[Dict], airport_iata: str, flight_date: da
|
||||
"scheduled_at": flight["scheduled_at"],
|
||||
"status": flight.get("status", "scheduled"),
|
||||
"source": flight["source"],
|
||||
"thread_title": flight.get("thread_title"),
|
||||
},
|
||||
)
|
||||
return len(flights)
|
||||
|
||||
Reference in New Issue
Block a user