Auto-fill aircraft type and airline from tail number #2

Merged
ronnyandre merged 1 commit from feat/tail-number-aircraft-lookup into main 2026-06-02 13:56:19 +02:00
Owner

Enter or edit a tail number on the flight form and the aircraft is looked up by registration via AeroDataBox /aircrafts/reg, auto-filling:

  • Aircraft type — matched to a seeded aircraft_type row by ICAO → IATA; inserts a new row when the type isn't seeded yet but has a real ICAO code. Always overwrites the field (registration is authoritative).
  • Operator airline — matched by name against seeded airlines; filled only when the field is empty (the operator can be a lessor and differ from the marketing carrier). Never inserts.

Reuses the existing cached getAircraftByReg lookup (in-memory + 30-day DB cache + API-call logging).

Changes

  • _enrichment-internal.ts: extract resolveAircraftType() (now optionally inserts), add matchAirlineByName() + runEnrichAircraftByReg(); buildPrefill keeps its existing no-insert behavior.
  • enrichment.ts: new enrichAircraftByReg POST server fn, gated by requireUserId.
  • flight-form.tsx: tail-number onBlur enrichment with spinner/note, request-id guard + dedup.

pnpm typecheck, pnpm lint, pnpm test (23/23) all pass.

Stacked on chore/green-up-codebase (PR #1) since that branch isn't merged yet and touches the same files. Retarget to main once #1 merges.

Enter or edit a tail number on the flight form and the aircraft is looked up by registration via AeroDataBox `/aircrafts/reg`, auto-filling: - **Aircraft type** — matched to a seeded `aircraft_type` row by ICAO → IATA; **inserts a new row** when the type isn't seeded yet but has a real ICAO code. Always overwrites the field (registration is authoritative). - **Operator airline** — matched by name against seeded airlines; filled only when the field is empty (the operator can be a lessor and differ from the marketing carrier). Never inserts. Reuses the existing cached `getAircraftByReg` lookup (in-memory + 30-day DB cache + API-call logging). ### Changes - `_enrichment-internal.ts`: extract `resolveAircraftType()` (now optionally inserts), add `matchAirlineByName()` + `runEnrichAircraftByReg()`; `buildPrefill` keeps its existing no-insert behavior. - `enrichment.ts`: new `enrichAircraftByReg` POST server fn, gated by `requireUserId`. - `flight-form.tsx`: tail-number `onBlur` enrichment with spinner/note, request-id guard + dedup. `pnpm typecheck`, `pnpm lint`, `pnpm test` (23/23) all pass. > Stacked on `chore/green-up-codebase` (PR #1) since that branch isn't merged yet and touches the same files. Retarget to `main` once #1 merges.
Enter (or edit) a tail number on the flight form and the aircraft is
looked up by registration via AeroDataBox /aircrafts/reg, auto-filling the
aircraft type — inserting a new aircraft_type reference row when the type
isn't seeded yet — plus the operator airline when it matches a seeded row.

- _enrichment-internal.ts: extract resolveAircraftType() (now optionally
  inserts a new aircraft_type when given a real ICAO code), add
  matchAirlineByName() and runEnrichAircraftByReg(); buildPrefill keeps its
  existing no-insert behavior
- enrichment.ts: new POST enrichAircraftByReg server fn, gated by
  requireUserId (it can mutate + hits the paid API)
- flight-form.tsx: tail-number onBlur enrichment with spinner/note;
  aircraft type overwrites, operator airline fills only when empty
ronnyandre changed target branch from chore/green-up-codebase to main 2026-06-02 13:56:17 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ronnyandre/fliary!2
No description provided.