mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The W8c picker pinned the device-type ladder to `pickedRows[0].type` for the entire bucket and walked one ladder for every row. The inline comment promised per-row resolution against the cached ladder map; the implementation never delivered it. Today's only caller — the `SLEEP_DURATION` aggregation in `/api/analytics` — feeds single-type rows so the gap is latent. Future callers (Coach evidence rollup, doctor-PDF section, correlations engine) that batch multiple MeasurementTypes through one picker call would have tested non-matching rows against the wrong ladder. Group present device-types per row-type, resolve each type's ladder from the cache, pick the winning device-type independently per type. Per-type fall-through covers the case where the user's custom ladder doesn't enumerate any device-type present for a given row-type. Cover the multi-type path with two new tests: - per-row ladder resolution preserves each type's winner - per-type fall-through when a custom ladder is unreachable