Ver código fonte

Changed to created_at by request

Jon Mårtensson 3 anos atrás
pai
commit
2679dc33e0

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

@@ -762,7 +762,7 @@ final class BaseAPSManager: APSManager, Injectable {
         }
         // Only run every hour
         if testIfEmpty != 0 {
-            guard testFile[0].createdAt.addingTimeInterval(1.hours.timeInterval) < Date() else {
+            guard testFile[0].created_at.addingTimeInterval(1.hours.timeInterval) < Date() else {
                 return
             }
         }
@@ -1179,7 +1179,7 @@ final class BaseAPSManager: APSManager, Injectable {
         )
 
         let dailystat = Statistics(
-            createdAt: Date(),
+            created_at: Date(),
             iPhone: UIDevice.current.getDeviceId,
             iOS: UIDevice.current.getOSInfo,
             Build_Version: version ?? "",
@@ -1204,10 +1204,10 @@ final class BaseAPSManager: APSManager, Injectable {
         )
 
         storage.transaction { storage in
-            storage.append(dailystat, to: file, uniqBy: \.createdAt)
+            storage.append(dailystat, to: file, uniqBy: \.created_at)
             var uniqeEvents: [Statistics] = storage.retrieve(file, as: [Statistics].self)?
-                .filter { $0.createdAt.addingTimeInterval(24.hours.timeInterval) > Date() }
-                .sorted { $0.createdAt > $1.createdAt } ?? []
+                .filter { $0.created_at.addingTimeInterval(24.hours.timeInterval) > Date() }
+                .sorted { $0.created_at > $1.created_at } ?? []
 
             storage.save(Array(uniqeEvents), as: file)
         }

+ 6 - 6
FreeAPS/Sources/Models/Statistics.swift

@@ -1,7 +1,7 @@
 import Foundation
 
 struct Statistics: JSON, Equatable {
-    var createdAt: Date
+    var created_at: Date
     var iPhone: String
     var iOS: String
     var Build_Version: String
@@ -19,7 +19,7 @@ struct Statistics: JSON, Equatable {
     var Statistics: Stats
 
     init(
-        createdAt: Date,
+        created_at: Date,
         iPhone: String,
         iOS: String,
         Build_Version: String,
@@ -36,7 +36,7 @@ struct Statistics: JSON, Equatable {
         GlucoseStorage_Days: Decimal,
         Statistics: Stats
     ) {
-        self.createdAt = createdAt
+        self.created_at = created_at
         self.iPhone = iPhone
         self.iOS = iOS
         self.Build_Version = Build_Version
@@ -55,17 +55,17 @@ struct Statistics: JSON, Equatable {
     }
 
     static func == (lhs: Statistics, rhs: Statistics) -> Bool {
-        lhs.createdAt == rhs.createdAt
+        lhs.created_at == rhs.created_at
     }
 
     func hash(into hasher: inout Hasher) {
-        hasher.combine(createdAt)
+        hasher.combine(created_at)
     }
 }
 
 extension Statistics {
     private enum CodingKeys: String, CodingKey {
-        case createdAt
+        case created_at
         case iPhone
         case iOS
         case Build_Version