feat: Let the stats day interval report on any day, not only today - #10
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 toconfuse 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 itsown 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.glucoseForStatsTodayis left in place. It has no callers now, butit 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