Jelajahi Sumber

Adjust and extend comment for conditional suggested import

Deniz Cengiz 1 tahun lalu
induk
melakukan
27b737b7af
1 mengubah file dengan 5 tambahan dan 3 penghapusan
  1. 5 3
      Model/JSONImporter.swift

+ 5 - 3
Model/JSONImporter.swift

@@ -324,9 +324,11 @@ class JSONImporter {
         backgroundContext.parent = context
 
         try await backgroundContext.perform {
-            /// We know both determination entries are from within last 24 hrs via the check in line 140
-            /// If their `deliverAt` does not match, it is worth storing them both
-            if suggestedDeliverAt != enactedDeliverAt {
+            
+            /// We know both determination entries are from within last 24 hrs via `checkDeterminationDate()` in the earlier `guard` clause
+            /// If their `deliverAt` does not match, and if `suggestedDeliverAt` is newer, it is worth storing them both, as that represents
+            /// a more recent algorithm run that did not cause a dosing enactment, e.g., a carb entry or a manual bolus.
+            if suggestedDeliverAt > enactedDeliverAt {
                 try suggestedDetermination.store(in: backgroundContext)
             }