Просмотр исходного кода

Fix Fetching carbs from NS.
Prepare for fetching fat and protein from Nightscout.

(cherry picked from commit c8e14b956aa27002ee140471c08b40b5b74424f9)

Jon Mårtensson 2 лет назад
Родитель
Сommit
cbf5bfa2d2

+ 2 - 0
FreeAPS/Sources/APS/Storage/CarbsStorage.swift

@@ -187,6 +187,8 @@ final class BaseCarbsStorage: CarbsStorage, Injectable {
                 insulin: nil,
                 notes: nil,
                 carbs: $0.carbs,
+                fat: nil,
+                protein: nil,
                 targetTop: nil,
                 targetBottom: nil
             )

+ 2 - 0
FreeAPS/Sources/APS/Storage/GlucoseStorage.swift

@@ -117,6 +117,8 @@ final class BaseGlucoseStorage: GlucoseStorage, Injectable {
                         insulin: nil,
                         notes: notes,
                         carbs: nil,
+                        fat: nil,
+                        protein: nil,
                         targetTop: nil,
                         targetBottom: nil
                     )

+ 12 - 0
FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift

@@ -230,6 +230,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                     insulin: nil,
                     notes: nil,
                     carbs: nil,
+                    fat: nil,
+                    protein: nil,
                     targetTop: nil,
                     targetBottom: nil
                 ))
@@ -260,6 +262,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                     insulin: event.amount,
                     notes: nil,
                     carbs: nil,
+                    fat: nil,
+                    protein: nil,
                     targetTop: nil,
                     targetBottom: nil
                 )
@@ -277,6 +281,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                     insulin: nil,
                     notes: nil,
                     carbs: Decimal(event.carbInput ?? 0),
+                    fat: nil,
+                    protein: nil,
                     targetTop: nil,
                     targetBottom: nil
                 )
@@ -300,6 +306,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                     insulin: nil,
                     notes: nil,
                     carbs: nil,
+                    fat: nil,
+                    protein: nil,
                     targetTop: nil,
                     targetBottom: nil
                 )
@@ -317,6 +325,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                     insulin: nil,
                     notes: nil,
                     carbs: nil,
+                    fat: nil,
+                    protein: nil,
                     targetTop: nil,
                     targetBottom: nil
                 )
@@ -334,6 +344,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                     insulin: nil,
                     notes: "Alarm \(String(describing: event.note)) \(event.type)",
                     carbs: nil,
+                    fat: nil,
+                    protein: nil,
                     targetTop: nil,
                     targetBottom: nil
                 )

+ 2 - 2
FreeAPS/Sources/Models/CarbsEntry.swift

@@ -4,8 +4,8 @@ struct CarbsEntry: JSON, Equatable, Hashable {
     let id: String?
     let createdAt: Date
     let carbs: Decimal
-    let fat: Decimal
-    let protein: Decimal
+    let fat: Decimal?
+    let protein: Decimal?
     let enteredBy: String?
     let isFPU: Bool?
     let fpuID: String?

+ 4 - 0
FreeAPS/Sources/Models/NightscoutTreatment.swift

@@ -13,6 +13,8 @@ struct NigtscoutTreatment: JSON, Hashable, Equatable {
     var insulin: Decimal?
     var notes: String?
     var carbs: Decimal?
+    var fat: Decimal?
+    var protein: Decimal?
     let targetTop: Decimal?
     let targetBottom: Decimal?
 
@@ -43,6 +45,8 @@ extension NigtscoutTreatment {
         case insulin
         case notes
         case carbs
+        case fat
+        case protein
         case targetTop
         case targetBottom
     }

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

@@ -392,6 +392,8 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
                 insulin: nil,
                 notes: nil,
                 carbs: nil,
+                fat: nil,
+                protein: nil,
                 targetTop: nil,
                 targetBottom: nil
             )