auto-sync: 2026-04-22 01:20:01
This commit is contained in:
@@ -484,6 +484,8 @@ def schedule_data():
|
||||
fa.registration,
|
||||
fa.operated_as,
|
||||
fa.category AS fa_category,
|
||||
fa.orig_iata AS fa_orig_iata,
|
||||
fa.dest_iata AS fa_dest_iata,
|
||||
-- из mart.flights (тип ВС):
|
||||
mf.aircraft_type,
|
||||
mf.track_source, mf.track_points
|
||||
@@ -550,6 +552,11 @@ def schedule_data():
|
||||
"sched_source": r.get("sched_source"),
|
||||
# Эффективная длительность: FA > schedule
|
||||
"duration_eff": r.get("fa_flight_time") or r.get("duration_min"),
|
||||
# Маршрут из FR24 (IATA коды → города)
|
||||
"fa_origin_iata": r.get("fa_orig_iata"),
|
||||
"fa_dest_iata": r.get("fa_dest_iata"),
|
||||
"fa_origin_city": _city(r.get("fa_orig_iata") or ""),
|
||||
"fa_dest_city": _city(r.get("fa_dest_iata") or ""),
|
||||
})
|
||||
|
||||
return ok({"total": total, "flights": flights})
|
||||
|
||||
@@ -276,9 +276,18 @@ function exportCsv() {
|
||||
// ── helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function routeStr(f) {
|
||||
// Prefer thread_title from Yandex (most accurate)
|
||||
// 1. Яндекс thread_title (приоритет 1)
|
||||
const tt = f.thread_title || "";
|
||||
if (tt) return tt;
|
||||
// 2. FR24 IATA коды → города (приоритет 2)
|
||||
const fo = f.fa_origin_city || f.fa_origin_iata || "";
|
||||
const fd = f.fa_dest_city || f.fa_dest_iata || "";
|
||||
if (fo || fd) {
|
||||
if (!fo) return `→ ${fd}`;
|
||||
if (!fd) return `${fo} →`;
|
||||
return `${fo} → ${fd}`;
|
||||
}
|
||||
// 3. Яндекс IATA → города (запасной вариант)
|
||||
const o = f.origin || "";
|
||||
const d = f.destination || "";
|
||||
if (!o && !d) return "—";
|
||||
|
||||
@@ -116,16 +116,20 @@ def upsert_flight_actual(conn, item: Dict, target_date: date) -> Optional[int]:
|
||||
"""
|
||||
INSERT INTO fr24_ext.flight_actual
|
||||
(fr24_id, flight, callsign, operated_as, origin_icao, dest_icao,
|
||||
orig_iata, dest_iata,
|
||||
datetime_takeoff, datetime_landed, flight_time,
|
||||
runway_takeoff, runway_landed, actual_distance, category,
|
||||
registration,
|
||||
flight_ended, first_seen, last_seen, flight_date)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
|
||||
ON CONFLICT (fr24_id) DO UPDATE SET
|
||||
flight = EXCLUDED.flight,
|
||||
callsign = EXCLUDED.callsign,
|
||||
operated_as = EXCLUDED.operated_as,
|
||||
origin_icao = EXCLUDED.origin_icao,
|
||||
dest_icao = EXCLUDED.dest_icao,
|
||||
orig_iata = EXCLUDED.orig_iata,
|
||||
dest_iata = EXCLUDED.dest_iata,
|
||||
datetime_takeoff = EXCLUDED.datetime_takeoff,
|
||||
datetime_landed = EXCLUDED.datetime_landed,
|
||||
flight_time = EXCLUDED.flight_time,
|
||||
@@ -133,6 +137,7 @@ def upsert_flight_actual(conn, item: Dict, target_date: date) -> Optional[int]:
|
||||
runway_landed = EXCLUDED.runway_landed,
|
||||
actual_distance = EXCLUDED.actual_distance,
|
||||
category = EXCLUDED.category,
|
||||
registration = EXCLUDED.registration,
|
||||
flight_ended = EXCLUDED.flight_ended,
|
||||
first_seen = EXCLUDED.first_seen,
|
||||
last_seen = EXCLUDED.last_seen,
|
||||
@@ -143,16 +148,19 @@ def upsert_flight_actual(conn, item: Dict, target_date: date) -> Optional[int]:
|
||||
fr24_id,
|
||||
item.get("flight"),
|
||||
item.get("callsign"),
|
||||
item.get("operated_as"),
|
||||
item.get("origin_icao"),
|
||||
item.get("destination_icao"),
|
||||
item.get("operating_as") or item.get("operated_as"), # FR24 uses operating_as
|
||||
item.get("orig_icao") or item.get("origin_icao"), # FR24 uses orig_icao
|
||||
item.get("dest_icao"),
|
||||
item.get("orig_iata"),
|
||||
item.get("dest_iata"),
|
||||
item.get("datetime_takeoff"),
|
||||
item.get("datetime_landed"),
|
||||
item.get("flight_time"),
|
||||
item.get("runway_takeoff"),
|
||||
item.get("runway_landed"),
|
||||
item.get("distance"),
|
||||
item.get("actual_distance") or item.get("distance"),
|
||||
item.get("category"),
|
||||
item.get("reg") or item.get("registration"), # FR24 uses reg
|
||||
item.get("flight_ended", False),
|
||||
item.get("first_seen"),
|
||||
item.get("last_seen"),
|
||||
|
||||
Reference in New Issue
Block a user