From 81b9ef71090d32645a90760b1490ee1b38201803 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 14 Jun 2018 13:30:16 -0700 Subject: [PATCH 1/2] Show carb absorption data for the past 24 hours --- Loop/View Controllers/CarbAbsorptionViewController.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Loop/View Controllers/CarbAbsorptionViewController.swift b/Loop/View Controllers/CarbAbsorptionViewController.swift index 6178a26104..220114547f 100644 --- a/Loop/View Controllers/CarbAbsorptionViewController.swift +++ b/Loop/View Controllers/CarbAbsorptionViewController.swift @@ -113,8 +113,9 @@ final class CarbAbsorptionViewController: ChartsTableViewController, Identifiabl } charts.startDate = chartStartDate - let midnight = Calendar.current.startOfDay(for: Date()) - let listStart = min(midnight, chartStartDate) + + let visiblePeriod = Calendar.current.date(byAdding: .hour, value: -24, to: Date()) ?? Calendar.current.startOfDay(for: Date()) + let listStart = min(visiblePeriod, chartStartDate) let reloadGroup = DispatchGroup() let shouldUpdateGlucose = currentContext.contains(.glucose) @@ -179,7 +180,7 @@ final class CarbAbsorptionViewController: ChartsTableViewController, Identifiabl if shouldUpdateCarbs { reloadGroup.enter() - self.deviceManager.loopManager.carbStore.getTotalCarbs(since: midnight) { (result) in + self.deviceManager.loopManager.carbStore.getTotalCarbs(since: visiblePeriod) { (result) in switch result { case .success(let total): carbTotal = total From 827753180ff56e01bdff7dbd20aa99c8aaae4e13 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 19 Jun 2018 14:11:46 -0700 Subject: [PATCH 2/2] Repair an issue with the latest merge; shift carb cutoff from midnight to the past 24 hours. --- Loop/View Controllers/CarbAbsorptionViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Loop/View Controllers/CarbAbsorptionViewController.swift b/Loop/View Controllers/CarbAbsorptionViewController.swift index 1ec0d68da2..8488e1d885 100644 --- a/Loop/View Controllers/CarbAbsorptionViewController.swift +++ b/Loop/View Controllers/CarbAbsorptionViewController.swift @@ -170,7 +170,7 @@ final class CarbAbsorptionViewController: ChartsTableViewController, Identifiabl if shouldUpdateCarbs { reloadGroup.enter() - self.deviceManager.loopManager.carbStore.getTotalCarbs(since: midnight) { (result) in + self.deviceManager.loopManager.carbStore.getTotalCarbs(since: visiblePeriod) { (result) in switch result { case .success(let total): carbTotal = total