fix(sleep): one day total for every sleep reader, and the latest night is a night

A day's sleep is the main night plus its naps (daySleepMinutes). The
series, the sleep score and the composition already read it that way; the
sleep list, the CSV export and the correlation sleep channel read the main
night alone, so a day of naps listed as 0 h and an average over the list
counted it as a night without sleep. The list now carries the day total in
value and the main night alone in the new mainAsleepMinutes field; the nap
caption reads as included.

GET /api/sleep/night without a date answered the latest day holding any
sleep, so a nap after the last night left the hypnogram with no night to
draw. It now walks back to the latest night with a main sleep; nap days
stay reachable by date.

The SQL night page bounded a night by its asleep sessions only, so an
in-bed-only session of the same night fell outside a chunked read that the
one-night read counted. The span now covers every session of the night.
This commit is contained in:
Marc-André Bombeck committed 2026-10-20 09:28:40 +02:00
1 parent 3004f55875
commit 63bbf0931c
20 files changed
+339 -94

No files matched your search

@@ -1989,9 +1989,9 @@ function DayDrillDown({
}
/**
* v1.11.5 — sub-caption for a per-night sleep row: surfaces the nap count
* (naps are separate from the main night per the nap convention) and the
* night's mid-sleep awakenings when present.
* Sub-caption for a per-night sleep row: the row's value is the day's sleep,
* main night plus naps, so the caption says how many naps it includes, and
* the night's mid-sleep awakenings when present.
*/
function SleepNightCaption({ m }: { m: Measurement }) {
const { t } = useTranslations();