Kaynağa Gözat

Add explicit logging for single bolus entries for TDD calc

Deniz Cengiz 1 yıl önce
ebeveyn
işleme
dd812b351c

+ 6 - 1
FreeAPS/Sources/APS/Storage/TDDStorage.swift

@@ -151,7 +151,12 @@ final class BaseTDDStorage: TDDStorage, Injectable {
     private func calculateBolusInsulin(_ bolusEvents: [PumpHistoryEvent]) -> Decimal {
     private func calculateBolusInsulin(_ bolusEvents: [PumpHistoryEvent]) -> Decimal {
         bolusEvents
         bolusEvents
             .reduce(Decimal(0)) { totalBolusInsulin, event in
             .reduce(Decimal(0)) { totalBolusInsulin, event in
-                totalBolusInsulin + (event.amount ?? 0)
+                let newTotalBolusInsulin = totalBolusInsulin + (event.amount as Decimal? ?? 0)
+                debug(
+                    .apsManager,
+                    "Bolus insulin \(event.amount ?? 0) U added. New total bolus = \(newTotalBolusInsulin) U"
+                )
+                return newTotalBolusInsulin
             }
             }
     }
     }