فهرست منبع

Remove unused variable; actually use allowed basal rate

Deniz Cengiz 1 سال پیش
والد
کامیت
98f501d7a6

+ 4 - 3
FreeAPS/Sources/Services/HealthKit/HealthKitManager.swift

@@ -511,12 +511,13 @@ final class BaseHealthKitManager: HealthKitManager, Injectable {
 
             // Calculate the insulin rate and adjusted delivered units
             let predecessorEntryRate = predecessorEntry.tempBasal?.rate?.doubleValue ?? 0
-            let adjustedDurationHours = adjustedDuration / 3600 // Precise duration in hours
-            let adjustedDeliveredUnits = adjustedDurationHours * predecessorEntryRate
-
+            
             // Round the rate to a supported basal rate using pumpManager's rounding function
             let roundedRate = deviceDataManager?.pumpManager?
                 .roundToSupportedBasalRate(unitsPerHour: predecessorEntryRate) ?? predecessorEntryRate
+            
+            let adjustedDurationHours = adjustedDuration / 3600 // Precise duration in hours
+            let adjustedDeliveredUnits = adjustedDurationHours * roundedRate
 
             // Recalculate the delivered units using the rounded rate
             let adjustedDeliveredUnitsRounded = adjustedDurationHours * adjustedDeliveredUnits

+ 0 - 1
FreeAPS/Sources/Services/Network/TidepoolManager.swift

@@ -459,7 +459,6 @@ extension BaseTidepoolManager {
 
             // Calculate the exact insulin delivered based on the duration in seconds
             let preciseDurationSeconds = TimeInterval(duration * 60) // Convert duration from minutes to seconds
-            let preciseDeliveredUnits = (Decimal(preciseDurationSeconds) / 3600) * amount
 
             // Find the corresponding temp basal entry in existingTempBasalEntries
             if let matchingEntryIndex = existingTempBasalEntries.firstIndex(where: { $0.timestamp == event.timestamp }) {