Procházet zdrojové kódy

Change Day stats to be able to scroll back 20 days instead of 10

polscm32 před 1 rokem
rodič
revize
8ec8eb0e3f

+ 1 - 3
Trio/Sources/Modules/Stat/StatStateModel+Setup/BolusStatsSetup.swift

@@ -71,10 +71,8 @@ extension Stat.StateModel {
             let calendar = Calendar.current
 
             // Group entries by hour for hourly statistics
-            // TODO: - Introduce paging to also be able to show complete history
-
             let now = Date()
-            let twentyDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: now) ?? now
+            let twentyDaysAgo = Calendar.current.date(byAdding: .day, value: -20, to: now) ?? now
 
             let hourlyGrouped = Dictionary(grouping: fetchedResults.filter { entry in
                 guard let date = entry.pumpEvent?.timestamp else { return false }

+ 1 - 3
Trio/Sources/Modules/Stat/StatStateModel+Setup/MealStatsSetup.swift

@@ -65,10 +65,8 @@ extension Stat.StateModel {
             let calendar = Calendar.current
 
             // Group entries by hour for hourly statistics
-            // TODO: - Introduce paging to also be able to show complete history
-
             let now = Date()
-            let twentyDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: now) ?? now
+            let twentyDaysAgo = Calendar.current.date(byAdding: .day, value: -20, to: now) ?? now
 
             let hourlyGrouped = Dictionary(grouping: fetchedResults.filter { entry in
                 guard let date = entry.date else { return false }

+ 3 - 4
Trio/Sources/Modules/Stat/StatStateModel+Setup/TDDSetup.swift

@@ -54,15 +54,14 @@ extension Stat.StateModel {
 
             let calendar = Calendar.current
 
-            // Calculate date range for hourly statistics (last 10 days)
-            // TODO: - Introduce paging to also be able to show complete history
+            // Calculate date range for hourly statistics (last 20 days)
             let now = Date()
-            let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: now) ?? now
+            let twentyDaysAgo = Calendar.current.date(byAdding: .day, value: -20, to: now) ?? now
 
             // Group entries by hour for hourly statistics, filtering for last 10 days only
             let hourlyGrouped = Dictionary(grouping: fetchedResults.filter { entry in
                 guard let date = entry.pumpEvent?.timestamp else { return false }
-                return date >= tenDaysAgo && date <= now
+                return date >= twentyDaysAgo && date <= now
             }) { entry in
                 // Create date components for hour-level grouping
                 let components = calendar.dateComponents(