Sam King 5 месяцев назад
Родитель
Сommit
ed78748bf9

+ 5 - 5
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DetermineBasalGenerator.swift

@@ -154,19 +154,19 @@ enum DeterminationGenerator {
             )
         }
 
-        let basal: Decimal
-        if let dynamicIsfResult = dynamicIsfResult, profile.tddAdjBasal {
+        var basal = profile.currentBasal ?? profile.basalFor(time: currentTime)
+        if dynamicIsfResult == nil {
             basal = computeAdjustedBasal(
                 profile: profile,
                 currentBasalRate: profile.currentBasal ?? profile.basalFor(time: currentTime),
-                sensitivityRatio: dynamicIsfResult.tddRatio,
+                sensitivityRatio: sensitivityRatio,
                 overrideFactor: trioCustomOrefVariables.overrideFactor()
             )
-        } else {
+        } else if let dynamicIsfResult = dynamicIsfResult, profile.tddAdjBasal {
             basal = computeAdjustedBasal(
                 profile: profile,
                 currentBasalRate: profile.currentBasal ?? profile.basalFor(time: currentTime),
-                sensitivityRatio: sensitivityRatio,
+                sensitivityRatio: dynamicIsfResult.tddRatio,
                 overrideFactor: trioCustomOrefVariables.overrideFactor()
             )
         }

+ 1 - 1
TrioTests/OpenAPSSwiftTests/DetermineBasalJsonTests.swift

@@ -103,7 +103,7 @@ import Testing
         // this test is meant for one-off analysis so it's ok to hard code
         // a file, just make sure to _not_ check in updates to this to
         // avoid polluting our change logs
-        let algorithmComparison = try await HttpFiles.downloadFile(at: "/files/795a9cf2-3d83-4f82-9dae-0035ed266da4.1.json")
+        let algorithmComparison = try await HttpFiles.downloadFile(at: "/files/3a461cc6-6c3e-4a25-91d7-0ca9fd52a9a5.2.json")
         let determineBasalInput = algorithmComparison.determineBasalInput!
 
         let encoder = JSONCoding.encoder