Skip to content

Commit 0da46c2

Browse files
authored
Updates for CarbStore api changes, and change default absorption times. (LoopKit#129)
1 parent 693a87c commit 0da46c2

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Loop/Managers/LoopDataManager.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ final class LoopDataManager {
6868
self.lockedBasalDeliveryState = Locked(basalDeliveryState)
6969
self.settings = settings
7070
self.overrideHistory = overrideHistory
71+
72+
let absorptionTimes = LoopSettings.defaultCarbAbsorptionTimes
73+
let cacheDuration = absorptionTimes.slow * 2
74+
75+
self.overrideHistory.relevantTimeWindow = cacheDuration
7176

7277
let healthStore = HKHealthStore()
7378

@@ -78,7 +83,8 @@ final class LoopDataManager {
7883
observeHealthKitForCurrentAppOnly: FeatureFlags.observeHealthKitForCurrentAppOnly,
7984
cacheStore: cacheStore,
8085
cacheLength: localCacheDuration,
81-
defaultAbsorptionTimes: LoopSettings.defaultCarbAbsorptionTimes,
86+
defaultAbsorptionTimes: absorptionTimes,
87+
observationInterval: cacheDuration,
8288
carbRatioSchedule: carbRatioSchedule,
8389
insulinSensitivitySchedule: insulinSensitivitySchedule,
8490
overrideHistory: overrideHistory,

LoopCore/LoopSettings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct LoopSettings: Equatable {
1313

1414
public let dynamicCarbAbsorptionEnabled = true
1515

16-
public static let defaultCarbAbsorptionTimes: CarbStore.DefaultAbsorptionTimes = (fast: .hours(2), medium: .hours(3), slow: .hours(4))
16+
public static let defaultCarbAbsorptionTimes: CarbStore.DefaultAbsorptionTimes = (fast: .minutes(30), medium: .hours(3), slow: .hours(5))
1717

1818
public var glucoseTargetRangeSchedule: GlucoseRangeSchedule?
1919

WatchApp Extension/Managers/LoopDataManager.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@ class LoopDataManager {
5353

5454
let healthStore = HKHealthStore()
5555
let cacheStore = PersistenceController.controllerInLocalDirectory()
56+
57+
let absorptionTimes = LoopSettings.defaultCarbAbsorptionTimes
58+
let cacheDuration = absorptionTimes.slow * 2
5659

5760
carbStore = CarbStore(
5861
healthStore: healthStore,
5962
observeHealthKitForCurrentAppOnly: FeatureFlags.observeHealthKitForCurrentAppOnly,
6063
cacheStore: cacheStore,
61-
defaultAbsorptionTimes: LoopSettings.defaultCarbAbsorptionTimes,
64+
cacheLength: cacheDuration,
65+
defaultAbsorptionTimes: absorptionTimes,
66+
observationInterval: cacheDuration,
6267
syncVersion: 0
6368
)
6469
glucoseStore = GlucoseStore(

0 commit comments

Comments
 (0)