Skip to content

Commit

Permalink
Ensure insulin effects cover glucose values for ICE calc when running…
Browse files Browse the repository at this point in the history
… forecast previews
  • Loading branch information
ps2 committed Aug 9, 2023
1 parent bdf9ca3 commit 7b234db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Loop/Managers/LoopDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1365,14 +1365,15 @@ extension LoopDataManager {
let retrospectiveStart = glucose.date.addingTimeInterval(-type(of: retrospectiveCorrection).retrospectionInterval)
let earliestEffectDate = Date(timeInterval: .hours(-24), since: now())
let nextEffectDate = insulinCounteractionEffects.last?.endDate ?? earliestEffectDate
let insulinEffectStartDate = nextEffectDate.addingTimeInterval(.minutes(-5))

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

var insulinEffect: [GlucoseEffect]?
let basalDosingEnd = includingPendingInsulin ? nil : now()
updateGroup.enter()
doseStore.getGlucoseEffects(start: nextEffectDate, end: nil, basalDosingEnd: basalDosingEnd) { result in
doseStore.getGlucoseEffects(start: insulinEffectStartDate, end: nil, basalDosingEnd: basalDosingEnd) { result in
switch result {
case .failure(let error):
effectCalculationError.mutate { $0 = error }
Expand Down

0 comments on commit 7b234db

Please sign in to comment.