Skip to content

feat: Let the stats day interval report on any day, not only today - #10

Merged
EJM0 merged 1 commit into
devfrom
feat/stats-day-picker
Sep 17, 2026
Merged

EJM0 merged 1 commit into
devfrom
feat/stats-day-picker

Conversation

@EJM0

@EJM0 EJM0 commented Sep 17, 2026

Copy link
Copy Markdown
Owner

The first segment of the stats duration picker was fixed to the current day:
"Today" meant midnight until now, and there was no way to look at yesterday, or
at the day of a meal that went badly. Every other segment is a rolling window
ending now, so nothing on the screen could answer "what did last Tuesday look
like".

That segment now chooses a day. It still opens on today, and a picker appears
beneath the segmented control while it is selected: chevrons for a day either
side, and a tap on the date for a calendar jump. Both ends are bounded — there
is no data past the screen's own three-month horizon, and none in the future.
The chosen day is held once for the whole screen rather than per tab, so moving
through days on the glucose tab and switching to looping keeps the day instead
of silently snapping back to today.

Two renames come with it. "Today" is no longer true of that segment, so it is
now "Day" — and that collides with the rolling 24 h window sitting next to it,
which was labelled "D". That one becomes "24 h", which is what it has always
been (its predicate is Date.oneDayAgo, not midnight). The two were easy to
confuse even before this change; one reads as an abbreviation of the other.

Under the hood the three places that turned an interval into a date range —
the glucose predicate and both loop-stat fetches — each carried their own copy
of the same switch, and each assumed the range ended at now. They now share
dateRange(for:), which returns both edges, so a day already past ends at its
own midnight rather than running up to the present. That also fixes the
loop-stat fetches, which previously had no upper bound at all; harmless while
every interval ended at now, wrong the moment one does not.

NSPredicate.glucoseForStatsToday is left in place. It has no callers now, but
it is a generic helper in the model layer rather than something this screen
owned.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01KeA9YkvARTKigZZ95CMSZT

The first segment of the stats duration picker was fixed to the current day:
"Today" meant midnight until now, and there was no way to look at yesterday, or
at the day of a meal that went badly. Every other segment is a rolling window
ending now, so nothing on the screen could answer "what did last Tuesday look
like".

That segment now chooses a day. It still opens on today, and a picker appears
beneath the segmented control while it is selected: chevrons for a day either
side, and a tap on the date for a calendar jump. Both ends are bounded — there
is no data past the screen's own three-month horizon, and none in the future.
The chosen day is held once for the whole screen rather than per tab, so moving
through days on the glucose tab and switching to looping keeps the day instead
of silently snapping back to today.

Two renames come with it. "Today" is no longer true of that segment, so it is
now "Day" — and that collides with the rolling 24 h window sitting next to it,
which was labelled "D". That one becomes "24 h", which is what it has always
been (its predicate is `Date.oneDayAgo`, not midnight). The two were easy to
confuse even before this change; one reads as an abbreviation of the other.

Under the hood the three places that turned an interval into a date range —
the glucose predicate and both loop-stat fetches — each carried their own copy
of the same switch, and each assumed the range ended at now. They now share
`dateRange(for:)`, which returns both edges, so a day already past ends at its
own midnight rather than running up to the present. That also fixes the
loop-stat fetches, which previously had no upper bound at all; harmless while
every interval ended at now, wrong the moment one does not.

`NSPredicate.glucoseForStatsToday` is left in place. It has no callers now, but
it is a generic helper in the model layer rather than something this screen
owned.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeA9YkvARTKigZZ95CMSZT
@EJM0
EJM0 merged commit d36394c into dev Sep 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants