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

Clean up in HomeDataFlow and HomeProvider

Deniz Cengiz 1 год назад
Родитель
Сommit
e77892c34b

+ 0 - 3
FreeAPS/Sources/Modules/Home/HomeDataFlow.swift

@@ -7,14 +7,11 @@ enum Home {
 
 protocol HomeProvider: Provider {
     func heartbeatNow()
-    func pumpHistory(hours: Int) -> [PumpHistoryEvent]
     func pumpSettings() -> PumpSettings
     func autotunedBasalProfile() -> [BasalProfileEntry]
     func basalProfile() -> [BasalProfileEntry]
     func tempTargets(hours: Int) -> [TempTarget]
-    func carbs(hours: Int) -> [CarbsEntry]
     func pumpReservoir() -> Decimal?
     func tempTarget() -> TempTarget?
     func announcement(_ hours: Int) -> [Announcement]
-    func fetchGlucose() -> [GlucoseStored]
 }

+ 0 - 18
FreeAPS/Sources/Modules/Home/HomeProvider.swift

@@ -6,9 +6,7 @@ extension Home {
     final class Provider: BaseProvider, HomeProvider {
         @Injected() var apsManager: APSManager!
         @Injected() var glucoseStorage: GlucoseStorage!
-        @Injected() var pumpHistoryStorage: PumpHistoryStorage!
         @Injected() var tempTargetsStorage: TempTargetsStorage!
-        @Injected() var carbsStorage: CarbsStorage!
         @Injected() var announcementStorage: AnnouncementsStorage!
 
         func pumpTimeZone() -> TimeZone? {
@@ -19,12 +17,6 @@ extension Home {
             apsManager.heartbeat(date: Date())
         }
 
-        func pumpHistory(hours: Int) -> [PumpHistoryEvent] {
-            pumpHistoryStorage.recent().filter {
-                $0.timestamp.addingTimeInterval(hours.hours.timeInterval) > Date()
-            }
-        }
-
         func tempTargets(hours: Int) -> [TempTarget] {
             tempTargetsStorage.recent().filter {
                 $0.createdAt.addingTimeInterval(hours.hours.timeInterval) > Date()
@@ -35,12 +27,6 @@ extension Home {
             tempTargetsStorage.current()
         }
 
-        func carbs(hours: Int) -> [CarbsEntry] {
-            carbsStorage.recent().filter {
-                $0.createdAt.addingTimeInterval(hours.hours.timeInterval) > Date()
-            }
-        }
-
         func announcement(_ hours: Int) -> [Announcement] {
             announcementStorage.validate().filter {
                 $0.createdAt.addingTimeInterval(hours.hours.timeInterval) > Date()
@@ -67,9 +53,5 @@ extension Home {
             storage.retrieve(OpenAPS.Settings.pumpProfile, as: Autotune.self)?.basalProfile
                 ?? [BasalProfileEntry(start: "00:00", minutes: 0, rate: 1)]
         }
-
-        func fetchGlucose() -> [GlucoseStored] {
-            glucoseStorage.fetchGlucose()
-        }
     }
 }

+ 2 - 1
FreeAPS/Sources/Modules/Home/HomeStateModel.swift

@@ -675,7 +675,8 @@ extension Home.StateModel {
                 .filter({ $0.type == EventType.pumpSuspend.rawValue || $0.type == EventType.pumpResume.rawValue })
             let lastSuspension = suspensions.last
 
-            pumpSuspended = tempBasals.last?.timestamp ?? Date() > lastSuspension?.timestamp ?? .distantPast && lastSuspension?.type == EventType.pumpSuspend
+            pumpSuspended = tempBasals.last?.timestamp ?? Date() > lastSuspension?.timestamp ?? .distantPast && lastSuspension?
+                .type == EventType.pumpSuspend
                 .rawValue
 
         } catch {