fix(airports): refresh the bundled airports from OurAirports without dropping shipped codes

Logroño-Agoncillo (RJL) and fifteen other airports gained their IATA code in
OurAirports after the bundled list was built, so the airport search and the
code lookup of create_transport could not find them. The list is rebuilt from
the current data. The build now keeps every code the previous list carried
that upstream no longer lists (a scheduled-service flag flipped back, PBI moved
to a new record), since bookings and MCP calls still name them.

Refs #2897
This commit is contained in:
Maurice
2026-10-30 21:26:19 +01:00
parent 067ab89430
commit 9f155a3191
3 changed files with 18 additions and 2 deletions
File diff suppressed because one or more lines are too long
+12 -1
View File
@@ -133,10 +133,21 @@ for (const a of airports) {
if (existing.icao && !a.icao) continue;
if (!existing.icao && a.icao) seen.set(a.iata, a);
}
// A code a release already shipped stays resolvable. OurAirports drops one when it
// flips a scheduled-service flag back to "no" or moves the code to a new record, and
// a booking import or an MCP call naming that code would stop resolving with the
// next rebuild. Upstream wins for every code it still lists.
const previous = fs.existsSync(OUT) ? JSON.parse(fs.readFileSync(OUT, 'utf8')) : [];
let kept = 0;
for (const a of previous) {
if (seen.has(a.iata)) continue;
seen.set(a.iata, a);
kept++;
}
const unique = Array.from(seen.values()).sort((a, b) => a.iata.localeCompare(b.iata));
fs.writeFileSync(OUT, JSON.stringify(unique));
const size = fs.statSync(OUT).size;
console.log(
`Wrote ${unique.length} airports to ${OUT} (${(size / 1024).toFixed(1)} KB); skipped ${skippedNoTz} without timezone`,
`Wrote ${unique.length} airports to ${OUT} (${(size / 1024).toFixed(1)} KB); kept ${kept} no longer listed; skipped ${skippedNoTz} without timezone`,
);
@@ -20,4 +20,9 @@ describe('bundled airport dataset', () => {
expect(findByIata(code), code).not.toBeNull();
}
});
it('AIRPORT-ASSET-003: carries the codes OurAirports gained since, Logroño among them (#2897)', () => {
expect(findByIata('RJL')).toMatchObject({ icao: 'LERJ', city: 'Logroño', country: 'ES', tz: 'Europe/Madrid' });
expect(findByIata('DXN')?.country).toBe('IN');
});
});