Browse Source

Update suspend interval to 24 hours

Sam King 2 tháng trước cách đây
mục cha
commit
d6a122a15e

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

@@ -84,8 +84,8 @@ extension NSPredicate {
         return NSPredicate(format: "timestamp >= %@", date as NSDate)
     }
 
-    static var pumpHistoryLast36h: NSPredicate {
-        let date = Date() - TimeInterval(hours: 36)
+    static var pumpHistoryLast48h: NSPredicate {
+        let date = Date() - TimeInterval(hours: 48)
         return NSPredicate(format: "timestamp >= %@", date as NSDate)
     }
 

+ 6 - 6
Trio/Sources/APS/OpenAPS/OpenAPS.swift

@@ -295,7 +295,7 @@ final class OpenAPS {
         let results = try await CoreDataStack.shared.fetchEntitiesAsync(
             ofType: PumpEventStored.self,
             onContext: context,
-            predicate: NSPredicate.pumpHistoryLast36h,
+            predicate: NSPredicate.pumpHistoryLast48h,
             key: "timestamp",
             ascending: true,
             batchSize: 250
@@ -310,9 +310,9 @@ final class OpenAPS {
                 .filter { $0.type == EventType.pumpSuspend.rawValue || $0.type == EventType.pumpResume.rawValue }
 
             // we define an orphaned resume as one without a paired suspend within
-            // the most recent 12 hours.
-            // **Important**: we pick 36 hours because the standard pump history
-            // is 24 hours + 12 hours of inspection for resumes.
+            // the most recent 24 hours.
+            // **Important**: we pick 48 hours because the standard pump history
+            // is 24 hours + 24 hours of inspection for resumes.
             let orphanedResumes = zip(pumpEventResults, pumpEventResults.dropFirst())
                 .compactMap { (prev, curr) -> PumpEventStored? in
                     guard let prevTimestamp = prev.timestamp, let currTimestamp = curr.timestamp else {
@@ -322,9 +322,9 @@ final class OpenAPS {
 
                     // check if the current event is an orphaned resume
                     //  - previous event not a suspend
-                    //  - previous event is a suspend but it's more than 12 hours ago
+                    //  - previous event is a suspend but it's more than 24 hours ago
                     if curr.type == EventType.pumpResume.rawValue,
-                       prev.type != EventType.pumpSuspend.rawValue || interval > TimeInterval(hours: 12)
+                       prev.type != EventType.pumpSuspend.rawValue || interval > TimeInterval(hours: 24)
                     {
                         return curr
                     }