Repository navigation
Show insulin per day since a setup change - #2659
Merged
Merged
Conversation
Current Setup always showed "–" for insulin per day since the change. The comparison only counts insulin when the dose history reaches the end of the period, and the history ends when it was loaded, but the comparison was then made with a fresh now() a moment later, so the period always ran past it. The view model now takes the time once, before the data loads, and compares against that. New test: the view model, with a clock that moves on with every reading, shows insulin per day since the change. It shows nothing without the fix.
Insulin per day before a change was blank unless the dose records covered all 3 weeks before it, so records starting a few days into the window left it blank. It is now averaged from when the records start, if that leaves at least 2 weeks, and a note says from when.
ps2
added a commit
to LoopKit/LoopWorkspace
that referenced
this pull request
Nov 5, 2026
…t-swift (#571) Loop: move the loop's types and cycle into LoopCore (LoopKit/Loop#2645), restore the watch app's G7SensorKit framework reference (LoopKit/Loop#2652), show the loop as open while a manual temp basal runs (LoopKit/Loop#2649), show insulin per day since a setup change (LoopKit/Loop#2659). LibreTransmitter: pair with libre2sim in the iOS Simulator (LoopKit/LibreTransmitter#62, #64); Libre 2 BLE records stamped with their correct age and smoothed over 5 minutes; incomplete BLE packets dropped. NightscoutService: space between the activity type and "Activity" in override reasons (LoopKit/NightscoutService#46). dexcom-share-client-swift: sort Share glucose before filterDateRange (LoopKit/dexcom-share-client-swift#62).
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.
Current Setup always showed "–" for Insulin per Day since the change.
SetupComparisononly counts insulin when the dose history reaches the end of the period (end <= history.end). The history ends when it was loaded. The comparison was then made with a freshnow()a moment later, so the "since change" period always ran past the history's end.CurrentSetupViewModelnow takes the time once inload(), before the data loads, and compares against that, also when another change is selected later.New test
testCurrentSetupShowsInsulinPerDaySinceTheChangeruns the view model with a clock that moves on with every reading:The existing
SetupComparisontests passed a fixednow, so they didn't catch this.SetupComparisonTestspass, run on the Loop that LoopWorkspace next-dev pins (29928c1) with this commit on top. Loop's next-dev tip needs a G7SensorKit change the workspace doesn't have yet.Before the change, from when the dose records start
The second commit stops "Before" being blank whenever the dose records start a few days into the 3 weeks before the change. The average now runs from when the records start, as long as that leaves at least 2 weeks. A note under the row says from when.
On a phone whose records start around Oct 5, a change on Oct 24 needs records from Oct 3, so "Before" was blank. It now shows about 19 days' average.
Two new tests:
SetupComparisonTests(11) pass.