mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 06:40:50 +00:00
Apple Watch Blood-Oxygen samples OXYGEN_SATURATION through the day and overnight. The readings map to latest aggregation and sit in neither the cumulative SUM drain nor the daily-mean drain, so every sample piled up raw forever. Fold out-of-window per-sample SpO2 rows to one daily-mean stats: row, soft-delete the raw rows, and preserve the daily min/max on the rollup DAY bucket via a pre-fold recompute — the lowest sample is the overnight desaturation nadir, the clinically meaningful figure the mean would hide. Generalise the PULSE min/max preservation to a min/max-preserving set so the pre-fold recompute and the skipped post-fold recompute cover both PULSE and SpO2; resting-HR derivation stays PULSE-only. RESPIRATORY_RATE is left to the existing daily-mean drain it already belongs to.