Преглед на файлове

Remove unused variable; actually use allowed basal rate

Deniz Cengiz преди 1 година
родител
ревизия
98f501d7a6
променени са 2 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 4 3
      FreeAPS/Sources/Services/HealthKit/HealthKitManager.swift
  2. 0 1
      FreeAPS/Sources/Services/Network/TidepoolManager.swift

+ 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
             // Calculate the insulin rate and adjusted delivered units
             let predecessorEntryRate = predecessorEntry.tempBasal?.rate?.doubleValue ?? 0
             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
             // Round the rate to a supported basal rate using pumpManager's rounding function
             let roundedRate = deviceDataManager?.pumpManager?
             let roundedRate = deviceDataManager?.pumpManager?
                 .roundToSupportedBasalRate(unitsPerHour: predecessorEntryRate) ?? predecessorEntryRate
                 .roundToSupportedBasalRate(unitsPerHour: predecessorEntryRate) ?? predecessorEntryRate
+            
+            let adjustedDurationHours = adjustedDuration / 3600 // Precise duration in hours
+            let adjustedDeliveredUnits = adjustedDurationHours * roundedRate
 
 
             // Recalculate the delivered units using the rounded rate
             // Recalculate the delivered units using the rounded rate
             let adjustedDeliveredUnitsRounded = adjustedDurationHours * adjustedDeliveredUnits
             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
             // Calculate the exact insulin delivered based on the duration in seconds
             let preciseDurationSeconds = TimeInterval(duration * 60) // Convert duration from minutes to 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
             // Find the corresponding temp basal entry in existingTempBasalEntries
             if let matchingEntryIndex = existingTempBasalEntries.firstIndex(where: { $0.timestamp == event.timestamp }) {
             if let matchingEntryIndex = existingTempBasalEntries.firstIndex(where: { $0.timestamp == event.timestamp }) {