From db88f76c4991bc2b88dfa30576acb0f3218dfbaf Mon Sep 17 00:00:00 2001 From: highflyer123 Date: Mon, 24 Aug 2026 17:17:25 -0700 Subject: [PATCH] Fix inverted condition on the max glucose count log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../LoopCaregiverKit/Nightscout/NightscoutDataSource.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LoopCaregiverKit/Sources/LoopCaregiverKit/Nightscout/NightscoutDataSource.swift b/LoopCaregiverKit/Sources/LoopCaregiverKit/Nightscout/NightscoutDataSource.swift index 106e2bda..ad60ef08 100644 --- a/LoopCaregiverKit/Sources/LoopCaregiverKit/Nightscout/NightscoutDataSource.swift +++ b/LoopCaregiverKit/Sources/LoopCaregiverKit/Nightscout/NightscoutDataSource.swift @@ -39,7 +39,7 @@ public class NightscoutDataSource: ObservableObject, RemoteDataServiceProvider { } }) .map({ $0.toGlucoseSample() }) - if result.count < maxFetchCount() { + if result.count >= maxFetchCount() { print("Hit max glucose count: Consider increasing") } return result