Fix inverted condition on the max glucose count log - #73
Open
highflyer123 wants to merge 1 commit into
Open
Conversation
The check was mechanically inverted in 6698b30 when assert(result.count < maxFetchCount(), "Hit max count: Consider increasing") became if result.count < maxFetchCount() { print("Hit max glucose count: Consider increasing") } The assert fired when its condition was violated; the `if` fires when the same condition holds, so the meaning is reversed. NightscoutKit passes `maxCount` straight through as Nightscout's `count=` query parameter, so `result.count` can never exceed `maxFetchCount()`. That makes the current condition true on every successful fetch and false in exactly the one case it exists to report — a fetch truncated at the limit. Inverting it to `>=` restores the original intent.
highflyer123
force-pushed
the
fix/glucose-max-count-log-condition
branch
from
August 25, 2026 00:32
252fc13 to
db88f76
Compare
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 change
Why
The condition was inverted in 6698b30 ("Remove assertion"), which rewrote
as
assertfires when its condition is violated; theiffires when it holds.result.countcan never exceedmaxFetchCount()—fetchGlucose(dateInterval:maxCount:)passesmaxCountthrough as Nightscout'scount=query parameter, and everything after it (compactMapinto[GlucoseEntry], then a 1:1toGlucoseSample()) can only shrink the array. Sothe warning prints on every successful fetch and stays silent in exactly the
case it exists to report — a fetch truncated at the cap.
>=rather than==so it still reports a server that ignorescount=.Diagnostic only —
resultis returned unchanged.Testing
Built and tested against
dev(fc86735), Xcode 26.2, iOS 26.2 simulator:LoopCaregiverKitand theLoopCaregiverapp scheme build clean, andLoopCaregiverKitTestspasses (9 tests, 0 failures).