Ver código fonte

fix IOB parsing

Ivan Valkou 5 anos atrás
pai
commit
101cd70cd0

+ 5 - 5
FreeAPS/Sources/Models/IOBEntry.swift

@@ -6,10 +6,10 @@ struct IOBEntry: JSON {
     let basaliob: Decimal
     let bolusiob: Decimal
     let netbasalinsulin: Decimal
-    let bolusinulin: Decimal
-    let iobWithZeroTemp: WithZeroTemp
-    let lastBolusTime: UInt64
-    let lastTemp: LastTemp
+    let bolusinsulin: Decimal
+    let iobWithZeroTemp: WithZeroTemp?
+    let lastBolusTime: UInt64?
+    let lastTemp: LastTemp?
     var timestamp: Date?
 
     struct WithZeroTemp: JSON {
@@ -18,7 +18,7 @@ struct IOBEntry: JSON {
         let basaliob: Decimal
         let bolusiob: Decimal
         let netbasalinsulin: Decimal
-        let bolusinulin: Decimal
+        let bolusinsulin: Decimal
         let time: Date
     }
 

+ 2 - 2
FreeAPS/Sources/Services/Network/NightscoutManager.swift

@@ -105,7 +105,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
     }
 
     func uploadStatus() {
-        let iob = (try? storage.retrieve(OpenAPS.Monitor.iob, as: [IOBEntry].self))?.first
+        let iob = try? storage.retrieve(OpenAPS.Monitor.iob, as: [IOBEntry].self)
         var suggested = try? storage.retrieve(OpenAPS.Enact.suggested, as: Suggestion.self)
         var enacted = try? storage.retrieve(OpenAPS.Enact.enacted, as: Suggestion.self)
 
@@ -116,7 +116,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
         }
 
         let openapsStatus = OpenAPSStatus(
-            iob: iob,
+            iob: iob?.first,
             suggested: suggested,
             enacted: enacted,
             version: "0.7.0"