From d88527316c827a9609e02be5ddb2bb1e66f21b60 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Mon, 28 May 2018 07:19:00 -0500 Subject: [PATCH] Consider values < 40mg/dL as unreliable --- Loop/Managers/CGM/DexCGMManager.swift | 2 +- Loop/Managers/LoopDataManager.swift | 20 +++++++++---------- .../AmplitudeService.swift | 1 + Loop/Models/ShareGlucose+GlucoseKit.swift | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Loop/Managers/CGM/DexCGMManager.swift b/Loop/Managers/CGM/DexCGMManager.swift index a6dfa6ba36..e7b5efc2ba 100644 --- a/Loop/Managers/CGM/DexCGMManager.swift +++ b/Loop/Managers/CGM/DexCGMManager.swift @@ -93,7 +93,7 @@ final class ShareClientManager: CGMManager { // Ignore glucose values that are up to a minute newer than our previous value, to account for possible time shifting in Share data let startDate = self.delegate?.startDateToFilterNewData(for: self)?.addingTimeInterval(TimeInterval(minutes: 1)) - let newGlucose = glucose.filterDateRange(startDate, nil).map { + let newGlucose = glucose.filterDateRange(startDate, nil).filter({ $0.isStateValid }).map { return (quantity: $0.quantity, date: $0.startDate, isDisplayOnly: false) } diff --git a/Loop/Managers/LoopDataManager.swift b/Loop/Managers/LoopDataManager.swift index 159a0f89d6..61a076ace0 100644 --- a/Loop/Managers/LoopDataManager.swift +++ b/Loop/Managers/LoopDataManager.swift @@ -890,8 +890,6 @@ final class LoopDataManager { throw LoopError.configurationError("Check settings") } - let pendingInsulin = try self.getPendingInsulin() - guard lastRequestedBolus == nil else { // Don't recommend changes if a bolus was just requested. @@ -903,20 +901,22 @@ final class LoopDataManager { } let tempBasal = predictedGlucose.recommendedTempBasal( - to: glucoseTargetRange, - suspendThreshold: settings.suspendThreshold?.quantity, - sensitivity: insulinSensitivity, - model: model, - basalRates: basalRates, - maxBasalRate: maxBasal, - lastTempBasal: lastTempBasal - ) + to: glucoseTargetRange, + suspendThreshold: settings.suspendThreshold?.quantity, + sensitivity: insulinSensitivity, + model: model, + basalRates: basalRates, + maxBasalRate: maxBasal, + lastTempBasal: lastTempBasal + ) if let temp = tempBasal { recommendedTempBasal = (recommendation: temp, date: startDate) } else { recommendedTempBasal = nil } + + let pendingInsulin = try self.getPendingInsulin() let recommendation = predictedGlucose.recommendedBolus( to: glucoseTargetRange, diff --git a/Loop/Models/ServiceAuthentication/AmplitudeService.swift b/Loop/Models/ServiceAuthentication/AmplitudeService.swift index f9a2e496d4..47d388d73e 100644 --- a/Loop/Models/ServiceAuthentication/AmplitudeService.swift +++ b/Loop/Models/ServiceAuthentication/AmplitudeService.swift @@ -46,6 +46,7 @@ class AmplitudeService: ServiceAuthentication { isAuthorized = true let client = Amplitude() + client.disableIdfaTracking() client.disableLocationListening() client.initializeApiKey(APIKey) self.client = client diff --git a/Loop/Models/ShareGlucose+GlucoseKit.swift b/Loop/Models/ShareGlucose+GlucoseKit.swift index f0854785a1..8b1e46294c 100644 --- a/Loop/Models/ShareGlucose+GlucoseKit.swift +++ b/Loop/Models/ShareGlucose+GlucoseKit.swift @@ -26,7 +26,7 @@ extension ShareGlucose: GlucoseValue { extension ShareGlucose: SensorDisplayable { public var isStateValid: Bool { - return glucose >= 20 + return glucose >= 39 } public var trendType: GlucoseTrend? {