Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
79 changes: 79 additions & 0 deletions meal_days/dev_meal_days.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Submodule Loop contains modified content
diff --git a/Loop/Loop/Managers/LoopDataManager.swift b/Loop/Loop/Managers/LoopDataManager.swift
index 2319f4ec..920ad2f9 100644
--- a/Loop/Loop/Managers/LoopDataManager.swift
+++ b/Loop/Loop/Managers/LoopDataManager.swift
@@ -992,6 +992,6 @@ extension LoopDataManager {

let retrospectiveStart = lastGlucoseDate.addingTimeInterval(-type(of: retrospectiveCorrection).retrospectionInterval)

- let earliestEffectDate = Date(timeInterval: .hours(-24), since: now())
+ let earliestEffectDate = Date(timeInterval: .hours(-2*24), since: now())
let nextCounteractionEffectDate = insulinCounteractionEffects.last?.endDate ?? earliestEffectDate
let insulinEffectStartDate = nextCounteractionEffectDate.addingTimeInterval(.minutes(-5))
diff --git a/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift b/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift
index fc770192..0b85b4c2 100644
--- a/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift
+++ b/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift
@@ -139,7 +139,7 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
charts.updateEndDate(chartStartDate.addingTimeInterval(.hours(totalHours+1))) // When there is no data, this allows presenting current hour + 1

let midnight = Calendar.current.startOfDay(for: Date())
- let listStart = min(midnight, chartStartDate, Date(timeIntervalSinceNow: -deviceManager.carbStore.maximumAbsorptionTimeInterval))
+ let earliestMidnight = midnight - .hours(1*24)

let reloadGroup = DispatchGroup()
let shouldUpdateGlucose = currentContext.contains(.glucose)
@@ -158,11 +158,19 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
let allInsulinCounteractionEffects = state.insulinCounteractionEffects
insulinCounteractionEffects = allInsulinCounteractionEffects.filterDateRange(chartStartDate, nil)

+ let earliestCounteractionEffect = allInsulinCounteractionEffects.first?.startDate ?? Date()
+ // Show carb entries back through midnight a week ago, or only as far back as counteraction effects are available
+ let boundOnCarbList = max(earliestMidnight, earliestCounteractionEffect)
+ // If counteraction effects are missing, at least show all the entries for today and those on the chart
+ let displayListStart = min(boundOnCarbList, midnight, chartStartDate)
+ // To estimate dynamic carb absorption for the entry at the start of the list, we need to fetch samples that might still be absorbing
+ let fetchEntriesStart = displayListStart.addingTimeInterval(-self.deviceManager.carbStore.maximumAbsorptionTimeInterval)
+
reloadGroup.enter()
- self.deviceManager.carbStore.getCarbStatus(start: listStart, end: nil, effectVelocities: allInsulinCounteractionEffects) { (result) in
+ self.deviceManager.carbStore.getCarbStatus(start: fetchEntriesStart, end: nil, effectVelocities: allInsulinCounteractionEffects) { (result) in
switch result {
case .success(let status):
- carbStatuses = status
+ carbStatuses = status.filterDateRange(displayListStart, nil)
carbsOnBoard = status.getClampedCarbsOnBoard()
case .failure(let error):
self.log.error("CarbStore failed to get carbStatus: %{public}@", String(describing: error))
@@ -287,6 +295,14 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
return formatter
}()

+ private lazy var relativeTimeFormatter: DateFormatter = {
+ let formatter = DateFormatter()
+ formatter.dateStyle = .medium
+ formatter.doesRelativeDateFormatting = true
+ formatter.timeStyle = .short
+ return formatter
+ }()
+
override func numberOfSections(in tableView: UITableView) -> Int {
return Section.count
}
@@ -343,7 +359,14 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
}

// Entry time
- let startTime = timeFormatter.string(from: status.entry.startDate)
+ let startTime: String
+ // Indicate if an entry is from the previous day to avoid potential confusion
+ let midnight = Calendar.current.startOfDay(for: Date())
+ if status.entry.startDate < midnight {
+ startTime = relativeTimeFormatter.string(from: status.entry.startDate)
+ } else {
+ startTime = timeFormatter.string(from: status.entry.startDate)
+ }
if let absorptionTime = status.entry.absorptionTime,
let duration = absorptionFormatter.string(from: absorptionTime)
{
File renamed without changes.
79 changes: 79 additions & 0 deletions meal_week/dev_meal_week.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Submodule Loop contains modified content
diff --git a/Loop/Loop/Managers/LoopDataManager.swift b/Loop/Loop/Managers/LoopDataManager.swift
index 2319f4ec..920ad2f9 100644
--- a/Loop/Loop/Managers/LoopDataManager.swift
+++ b/Loop/Loop/Managers/LoopDataManager.swift
@@ -992,6 +992,6 @@ extension LoopDataManager {

let retrospectiveStart = lastGlucoseDate.addingTimeInterval(-type(of: retrospectiveCorrection).retrospectionInterval)

- let earliestEffectDate = Date(timeInterval: .hours(-24), since: now())
+ let earliestEffectDate = Date(timeInterval: .hours(-7*24), since: now())
let nextCounteractionEffectDate = insulinCounteractionEffects.last?.endDate ?? earliestEffectDate
let insulinEffectStartDate = nextCounteractionEffectDate.addingTimeInterval(.minutes(-5))
diff --git a/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift b/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift
index fc770192..0b85b4c2 100644
--- a/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift
+++ b/Loop/Loop/View Controllers/CarbAbsorptionViewController.swift
@@ -139,7 +139,7 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
charts.updateEndDate(chartStartDate.addingTimeInterval(.hours(totalHours+1))) // When there is no data, this allows presenting current hour + 1

let midnight = Calendar.current.startOfDay(for: Date())
- let listStart = min(midnight, chartStartDate, Date(timeIntervalSinceNow: -deviceManager.carbStore.maximumAbsorptionTimeInterval))
+ let earliestMidnight = midnight - .hours(6*24)

let reloadGroup = DispatchGroup()
let shouldUpdateGlucose = currentContext.contains(.glucose)
@@ -158,11 +158,19 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
let allInsulinCounteractionEffects = state.insulinCounteractionEffects
insulinCounteractionEffects = allInsulinCounteractionEffects.filterDateRange(chartStartDate, nil)

+ let earliestCounteractionEffect = allInsulinCounteractionEffects.first?.startDate ?? Date()
+ // Show carb entries back through midnight a week ago, or only as far back as counteraction effects are available
+ let boundOnCarbList = max(earliestMidnight, earliestCounteractionEffect)
+ // If counteraction effects are missing, at least show all the entries for today and those on the chart
+ let displayListStart = min(boundOnCarbList, midnight, chartStartDate)
+ // To estimate dynamic carb absorption for the entry at the start of the list, we need to fetch samples that might still be absorbing
+ let fetchEntriesStart = displayListStart.addingTimeInterval(-self.deviceManager.carbStore.maximumAbsorptionTimeInterval)
+
reloadGroup.enter()
- self.deviceManager.carbStore.getCarbStatus(start: listStart, end: nil, effectVelocities: allInsulinCounteractionEffects) { (result) in
+ self.deviceManager.carbStore.getCarbStatus(start: fetchEntriesStart, end: nil, effectVelocities: allInsulinCounteractionEffects) { (result) in
switch result {
case .success(let status):
- carbStatuses = status
+ carbStatuses = status.filterDateRange(displayListStart, nil)
carbsOnBoard = status.getClampedCarbsOnBoard()
case .failure(let error):
self.log.error("CarbStore failed to get carbStatus: %{public}@", String(describing: error))
@@ -287,6 +295,14 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
return formatter
}()

+ private lazy var relativeTimeFormatter: DateFormatter = {
+ let formatter = DateFormatter()
+ formatter.dateStyle = .medium
+ formatter.doesRelativeDateFormatting = true
+ formatter.timeStyle = .short
+ return formatter
+ }()
+
override func numberOfSections(in tableView: UITableView) -> Int {
return Section.count
}
@@ -343,7 +359,14 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
}

// Entry time
- let startTime = timeFormatter.string(from: status.entry.startDate)
+ let startTime: String
+ // Indicate if an entry is from the previous day to avoid potential confusion
+ let midnight = Calendar.current.startOfDay(for: Date())
+ if status.entry.startDate < midnight {
+ startTime = relativeTimeFormatter.string(from: status.entry.startDate)
+ } else {
+ startTime = timeFormatter.string(from: status.entry.startDate)
+ }
if let absorptionTime = status.entry.absorptionTime,
let duration = absorptionFormatter.string(from: absorptionTime)
{