Jon Mårtensson 3 年之前
父节点
当前提交
b80128d6c2
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      FreeAPS/Sources/APS/APSManager.swift

+ 2 - 2
FreeAPS/Sources/APS/APSManager.swift

@@ -671,8 +671,8 @@ final class BaseAPSManager: APSManager, Injectable {
         storage.transaction { storage in
             storage.append(tdd, to: file, uniqBy: \.id)
             uniqEvents = storage.retrieve(file, as: [TDD].self)?
-                .sorted { $0.timestamp > $1.timestamp } ?? []
                 .filter { $0.timestamp.addingTimeInterval(14.days.timeInterval) > Date() }
+                .sorted { $0.timestamp > $1.timestamp } ?? []
             var total: Decimal = 0
             var indeces: Decimal = 0
             for uniqEvent in uniqEvents {
@@ -682,8 +682,8 @@ final class BaseAPSManager: APSManager, Injectable {
                 }
             }
             let entriesPast2hours = storage.retrieve(file, as: [TDD].self)?
-                .sorted { $0.timestamp > $1.timestamp } ?? []
                 .filter { $0.timestamp.addingTimeInterval(2.hours.timeInterval) > Date() }
+                .sorted { $0.timestamp > $1.timestamp } ?? []
             var totalAmount: Decimal = 0
             var nrOfIndeces: Decimal = 0
             for entry in entriesPast2hours {