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

attempt to fix duplicate history entries...wip, async refactoring also possibly coming soon

polscm32 1 год назад
Родитель
Сommit
19a4778fe1

+ 1 - 1
FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift

@@ -46,7 +46,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                     let existingEvents: [PumpEventStored] = CoreDataStack.shared.fetchEntities(
                         ofType: PumpEventStored.self,
                         onContext: self.context,
-                        predicate: NSPredicate.duplicateInLastFourLoops(event.date),
+                        predicate: NSPredicate.duplicateInLastHour(event.date),
                         key: "timestamp",
                         ascending: false,
                         batchSize: 50

+ 3 - 3
Model/Helper/PumpEvent+helper.swift

@@ -68,9 +68,9 @@ extension NSPredicate {
         return NSPredicate(format: "timestamp >= %@ AND bolus.isExternal == %@", date as NSDate, false as NSNumber)
     }
 
-    static func duplicateInLastFourLoops(_ date: Date) -> NSPredicate {
-        let date20m = Date.twentyMinutesAgo
-        return NSPredicate(format: "timestamp >= %@ && timestamp == %@", date20m as NSDate, date as NSDate)
+    static func duplicateInLastHour(_ date: Date) -> NSPredicate {
+        let date60m = Date.oneHourAgo
+        return NSPredicate(format: "timestamp >= %@ && timestamp == %@", date60m as NSDate, date as NSDate)
     }
 
     static var pumpEventsNotYetUploadedToNightscout: NSPredicate {