Skip to content

Commit 7b234db

Browse files
committed
Ensure insulin effects cover glucose values for ICE calc when running forecast previews
1 parent bdf9ca3 commit 7b234db

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Loop/Managers/LoopDataManager.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,14 +1365,15 @@ extension LoopDataManager {
13651365
let retrospectiveStart = glucose.date.addingTimeInterval(-type(of: retrospectiveCorrection).retrospectionInterval)
13661366
let earliestEffectDate = Date(timeInterval: .hours(-24), since: now())
13671367
let nextEffectDate = insulinCounteractionEffects.last?.endDate ?? earliestEffectDate
1368+
let insulinEffectStartDate = nextEffectDate.addingTimeInterval(.minutes(-5))
13681369

13691370
let updateGroup = DispatchGroup()
13701371
let effectCalculationError = Locked<Error?>(nil)
13711372

13721373
var insulinEffect: [GlucoseEffect]?
13731374
let basalDosingEnd = includingPendingInsulin ? nil : now()
13741375
updateGroup.enter()
1375-
doseStore.getGlucoseEffects(start: nextEffectDate, end: nil, basalDosingEnd: basalDosingEnd) { result in
1376+
doseStore.getGlucoseEffects(start: insulinEffectStartDate, end: nil, basalDosingEnd: basalDosingEnd) { result in
13761377
switch result {
13771378
case .failure(let error):
13781379
effectCalculationError.mutate { $0 = error }

0 commit comments

Comments
 (0)