ADSB debugging

This commit is contained in:
2026-06-27 16:14:06 -04:00
parent a4f13d87ab
commit 579eed746e
2 changed files with 15 additions and 9 deletions

View File

@@ -229,14 +229,18 @@ export async function enrichAircraft(a) {
// 1. Check own DB first
const row = db.prepare('SELECT * FROM aircraft WHERE icao24 = ?').get(icao);
if (row?.manufacturer && row?.model) {
return { ...a, ...row, type: classifyAircraft(row) };
}
if(row?.manufacturer && row?.model) return { ...a, ...row, type: classifyAircraft(row) };
// 2. Race the two external sources
let found = await Promise.any([
fetchHexDb(icao),
scrapeHexDatabase(icao),
fetchHexDb(icao).then(resp => {
console.log(`source1: ${icao}`, resp);
return resp;
}),
scrapeHexDatabase(icao).then(resp => {
console.log(`source2: ${icao}`, resp);
return resp;
}),
]).catch(() => null);
// Merge with any partial DB row we already have
@@ -248,6 +252,8 @@ export async function enrichAircraft(a) {
Object.assign(merged, { ...similar, ...merged }); // don't overwrite fetched data
}
console.log(`Backfilling: ${icao}`, merged);
// 4. Save back to DB
if (found) {
db.prepare(`