Files
meshcore-analyzer/cmd/server
Alex BandClaude Opus 5.5 ca62790c81 fix(store): load the observer IATA in the background chunk loader (#2185)
## Problem
With `hotStartupHours` set, startup loads the hot window first.
`loadChunk` then fills the rest of the retention window in the
background. Its query selected the observer ID and name but not the IATA
code, and scanned no IATA, so every packet it loaded had an empty
`ObserverIATA`. On a 7-day window with a 24 h hot start, that's six days
of packets after every restart that:
- have no `observer_iata` in the packets API;
- never match the `iata` filter (#1188).

`Load`, `scanAndMergeChunk` (the hot window) and both ingest paths
already join `observers` to get the IATA code, so only background-loaded
packets were affected.

**Seen on a live instance** (`hotStartupHours: 24`, restarted about 18 h
earlier), sampling `/api/packets?until=…`:

| packets | with `observer_iata` |
|---|---|
| 20–30 h old (hot window) | 200 / 200 |
| 46 h old (background-loaded) | 0 / 200 |
| 60 h old (background-loaded) | 0 / 200 |

With this fix on a staging instance, packets older than its hot window
are 300 / 300.

## Change
The chunk query selects `COALESCE(obs.iata, '')` for both schemas: the
v3 query through the observers join it already had, and the legacy query
through a new join on the observer ID, as `Load` does. `loadChunk` scans
the column into `ObserverIATA`.

## Tests
- `TestLoadChunkKeepsObserverIATA`: red commit first (fails on its
assertion), then green.
- `cd cmd/server && go test ./...` passes.
- SonarQube: quality gate passed, no issues on added lines.

**Overlap with #2183:** both edit the same lines of `loadChunk`'s
`StoreObs` literal (#2183 interns the observer fields). Whichever lands
second needs a trivial rebase; if this lands first, #2183 should intern
`ObserverIATA` there too. There's no code dependency.

Backend only: no UI, API shape or config change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 11:13:53 +02:00
..