Просмотр исходного кода

Add filtering for old meals in Autosens

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

+ 3 - 2
Trio/Sources/APS/OpenAPSSwift/Autosens/AutosensGenerator.swift

@@ -311,9 +311,10 @@ struct AutosensGenerator {
         history: [PumpHistoryEvent],
         carbs: [CarbsEntry],
         profile _: Profile,
-        bucketedGlucose _: [BucketedGlucose]
+        bucketedGlucose: [BucketedGlucose]
     ) -> [MealInput] {
-        let meals = MealHistory.findMealInputs(pumpHistory: history, carbHistory: carbs)
+        let oldestGlucose = bucketedGlucose.first?.date ?? .distantPast
+        let meals = MealHistory.findMealInputs(pumpHistory: history, carbHistory: carbs).filter { $0.timestamp >= oldestGlucose }
 
         return meals.sorted(by: { $0.timestamp > $1.timestamp })
     }

+ 1 - 1
TrioTests/OpenAPSSwiftTests/AutosensJsonTests.swift

@@ -199,7 +199,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/b1d693c2-6432-4742-bc68-aebf02386229.0.json")
+        let algorithmComparison = try await HttpFiles.downloadFile(at: "/files/432be489-adfd-4799-b469-8d3794d5188e.0.json")
         let autosensInputs = algorithmComparison.autosensInput!
 
         let encoder = JSONCoding.encoder