ADSB backfill fix?

This commit is contained in:
2026-06-27 17:16:59 -04:00
parent 2ccacf563c
commit 946ccd67e1

View File

@@ -190,7 +190,11 @@ async function scrapeHexDatabase(icao) {
const resp = await fetch(url);
if (!resp.ok) return null;
const $ = cheerio.load(await resp.text());
const html = await resp.text();
const tableMatch = html.match(/<table[\s\S]*?<\/table>/i);
if (!tableMatch) return null;
const $ = cheerio.load(tableMatch[0]);
const row = $('tr').filter((_, el) => $(el).text().toLowerCase().includes(icao.toLowerCase())).first();
if (!row.length) return null;
@@ -229,7 +233,7 @@ export async function enrichAircraft(a) {
// 1. Check own DB first
const row = db.prepare('SELECT * FROM aircraft WHERE icao = ?').get(icao);
if(row?.manufacturer && row?.model) return { ...a, ...row, type: classifyAircraft(row) };
if(row?.aircraft) return { ...a, ...row, type: classifyAircraft(row) };
// 2. Race the two external sources
if(noRecord.includes(icao)) return { icao, ...a, type: 'unknown' };