Skip to content

Commit e18e2ad

Browse files
authored
Track whether bolus was delivered automatically (#1480)
* Track whether bolus was delivered automatically * Fix tests
1 parent 15b3fc7 commit e18e2ad

17 files changed

+63
-109
lines changed

Loop.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4573,7 +4573,7 @@
45734573
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
45744574
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
45754575
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
4576-
DEVELOPMENT_TEAM = UY678SP37Q;
4576+
DEVELOPMENT_TEAM = "";
45774577
INFOPLIST_FILE = Loop/Info.plist;
45784578
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
45794579
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -4595,7 +4595,7 @@
45954595
CODE_SIGN_ENTITLEMENTS = "$(LOOP_ENTITLEMENTS)";
45964596
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
45974597
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
4598-
DEVELOPMENT_TEAM = UY678SP37Q;
4598+
DEVELOPMENT_TEAM = "";
45994599
INFOPLIST_FILE = Loop/Info.plist;
46004600
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
46014601
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -4614,7 +4614,7 @@
46144614
CODE_SIGN_ENTITLEMENTS = "WatchApp Extension/WatchApp Extension.entitlements";
46154615
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
46164616
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
4617-
DEVELOPMENT_TEAM = UY678SP37Q;
4617+
DEVELOPMENT_TEAM = "";
46184618
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
46194619
INFOPLIST_FILE = "WatchApp Extension/Info.plist";
46204620
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
@@ -4636,7 +4636,7 @@
46364636
CODE_SIGN_ENTITLEMENTS = "WatchApp Extension/WatchApp Extension.entitlements";
46374637
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
46384638
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
4639-
DEVELOPMENT_TEAM = UY678SP37Q;
4639+
DEVELOPMENT_TEAM = "";
46404640
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
46414641
INFOPLIST_FILE = "WatchApp Extension/Info.plist";
46424642
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
@@ -4658,7 +4658,7 @@
46584658
ASSETCATALOG_COMPILER_APPICON_NAME = "$(APPICON_NAME)";
46594659
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
46604660
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
4661-
DEVELOPMENT_TEAM = UY678SP37Q;
4661+
DEVELOPMENT_TEAM = "";
46624662
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
46634663
IBSC_MODULE = WatchApp_Extension;
46644664
INFOPLIST_FILE = WatchApp/Info.plist;
@@ -4680,7 +4680,7 @@
46804680
ASSETCATALOG_COMPILER_APPICON_NAME = "$(APPICON_NAME)";
46814681
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
46824682
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
4683-
DEVELOPMENT_TEAM = UY678SP37Q;
4683+
DEVELOPMENT_TEAM = "";
46844684
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
46854685
IBSC_MODULE = WatchApp_Extension;
46864686
INFOPLIST_FILE = WatchApp/Info.plist;
@@ -4847,7 +4847,7 @@
48474847
CODE_SIGN_ENTITLEMENTS = "Loop Status Extension/Loop Status Extension.entitlements";
48484848
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
48494849
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
4850-
DEVELOPMENT_TEAM = UY678SP37Q;
4850+
DEVELOPMENT_TEAM = "";
48514851
ENABLE_BITCODE = NO;
48524852
INFOPLIST_FILE = "Loop Status Extension/Info.plist";
48534853
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
@@ -4866,7 +4866,7 @@
48664866
CODE_SIGN_ENTITLEMENTS = "Loop Status Extension/Loop Status Extension.entitlements";
48674867
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
48684868
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
4869-
DEVELOPMENT_TEAM = UY678SP37Q;
4869+
DEVELOPMENT_TEAM = "";
48704870
ENABLE_BITCODE = NO;
48714871
INFOPLIST_FILE = "Loop Status Extension/Info.plist";
48724872
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
@@ -4931,7 +4931,7 @@
49314931
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
49324932
CODE_SIGN_STYLE = Automatic;
49334933
CURRENT_PROJECT_VERSION = 57;
4934-
DEVELOPMENT_TEAM = UY678SP37Q;
4934+
DEVELOPMENT_TEAM = "";
49354935
GCC_DYNAMIC_NO_PIC = NO;
49364936
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
49374937
INFOPLIST_FILE = "Loop Intent Extension/Info.plist";
@@ -4968,7 +4968,7 @@
49684968
CODE_SIGN_STYLE = Automatic;
49694969
CURRENT_PROJECT_VERSION = 57;
49704970
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
4971-
DEVELOPMENT_TEAM = UY678SP37Q;
4971+
DEVELOPMENT_TEAM = "";
49724972
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
49734973
INFOPLIST_FILE = "Loop Intent Extension/Info.plist";
49744974
IPHONEOS_DEPLOYMENT_TARGET = 13.0;

Loop.xcodeproj/xcshareddata/xcschemes/Complication - WatchApp.xcscheme

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,16 @@
8888
debugServiceExtension = "internal"
8989
allowLocationSimulation = "YES"
9090
launchAutomaticallySubstyle = "32">
91-
<RemoteRunnable
92-
runnableDebuggingMode = "2"
93-
BundleIdentifier = "com.apple.Carousel"
94-
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
91+
<BuildableProductRunnable
92+
runnableDebuggingMode = "0">
9593
<BuildableReference
9694
BuildableIdentifier = "primary"
9795
BlueprintIdentifier = "43A943711B926B7B0051FA24"
9896
BuildableName = "WatchApp.app"
9997
BlueprintName = "WatchApp"
10098
ReferencedContainer = "container:Loop.xcodeproj">
10199
</BuildableReference>
102-
</RemoteRunnable>
100+
</BuildableProductRunnable>
103101
</LaunchAction>
104102
<ProfileAction
105103
buildConfiguration = "Release"
@@ -108,27 +106,16 @@
108106
useCustomWorkingDirectory = "NO"
109107
debugDocumentVersioning = "YES"
110108
launchAutomaticallySubstyle = "32">
111-
<RemoteRunnable
112-
runnableDebuggingMode = "2"
113-
BundleIdentifier = "com.apple.Carousel"
114-
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
109+
<BuildableProductRunnable
110+
runnableDebuggingMode = "0">
115111
<BuildableReference
116112
BuildableIdentifier = "primary"
117113
BlueprintIdentifier = "43A943711B926B7B0051FA24"
118114
BuildableName = "WatchApp.app"
119115
BlueprintName = "WatchApp"
120116
ReferencedContainer = "container:Loop.xcodeproj">
121117
</BuildableReference>
122-
</RemoteRunnable>
123-
<MacroExpansion>
124-
<BuildableReference
125-
BuildableIdentifier = "primary"
126-
BlueprintIdentifier = "43A943711B926B7B0051FA24"
127-
BuildableName = "WatchApp.app"
128-
BlueprintName = "WatchApp"
129-
ReferencedContainer = "container:Loop.xcodeproj">
130-
</BuildableReference>
131-
</MacroExpansion>
118+
</BuildableProductRunnable>
132119
</ProfileAction>
133120
<AnalyzeAction
134121
buildConfiguration = "Debug">

Loop.xcodeproj/xcshareddata/xcschemes/Notification - WatchApp.xcscheme

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,16 @@
8989
allowLocationSimulation = "YES"
9090
launchAutomaticallySubstyle = "8"
9191
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
92-
<RemoteRunnable
93-
runnableDebuggingMode = "2"
94-
BundleIdentifier = "com.apple.Carousel"
95-
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
92+
<BuildableProductRunnable
93+
runnableDebuggingMode = "0">
9694
<BuildableReference
9795
BuildableIdentifier = "primary"
9896
BlueprintIdentifier = "43A943711B926B7B0051FA24"
9997
BuildableName = "WatchApp.app"
10098
BlueprintName = "WatchApp"
10199
ReferencedContainer = "container:Loop.xcodeproj">
102100
</BuildableReference>
103-
</RemoteRunnable>
101+
</BuildableProductRunnable>
104102
</LaunchAction>
105103
<ProfileAction
106104
buildConfiguration = "Release"
@@ -110,27 +108,16 @@
110108
debugDocumentVersioning = "YES"
111109
launchAutomaticallySubstyle = "8"
112110
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
113-
<RemoteRunnable
114-
runnableDebuggingMode = "2"
115-
BundleIdentifier = "com.apple.Carousel"
116-
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
111+
<BuildableProductRunnable
112+
runnableDebuggingMode = "0">
117113
<BuildableReference
118114
BuildableIdentifier = "primary"
119115
BlueprintIdentifier = "43A943711B926B7B0051FA24"
120116
BuildableName = "WatchApp.app"
121117
BlueprintName = "WatchApp"
122118
ReferencedContainer = "container:Loop.xcodeproj">
123119
</BuildableReference>
124-
</RemoteRunnable>
125-
<MacroExpansion>
126-
<BuildableReference
127-
BuildableIdentifier = "primary"
128-
BlueprintIdentifier = "43A943711B926B7B0051FA24"
129-
BuildableName = "WatchApp.app"
130-
BlueprintName = "WatchApp"
131-
ReferencedContainer = "container:Loop.xcodeproj">
132-
</BuildableReference>
133-
</MacroExpansion>
120+
</BuildableProductRunnable>
134121
</ProfileAction>
135122
<AnalyzeAction
136123
buildConfiguration = "Debug">

Loop.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,16 @@
8888
debugServiceExtension = "internal"
8989
allowLocationSimulation = "YES"
9090
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
91-
<RemoteRunnable
92-
runnableDebuggingMode = "2"
93-
BundleIdentifier = "com.apple.Carousel"
94-
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
91+
<BuildableProductRunnable
92+
runnableDebuggingMode = "0">
9593
<BuildableReference
9694
BuildableIdentifier = "primary"
9795
BlueprintIdentifier = "43A943711B926B7B0051FA24"
9896
BuildableName = "WatchApp.app"
9997
BlueprintName = "WatchApp"
10098
ReferencedContainer = "container:Loop.xcodeproj">
10199
</BuildableReference>
102-
</RemoteRunnable>
100+
</BuildableProductRunnable>
103101
</LaunchAction>
104102
<ProfileAction
105103
buildConfiguration = "Release"
@@ -108,27 +106,16 @@
108106
useCustomWorkingDirectory = "NO"
109107
debugDocumentVersioning = "YES"
110108
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
111-
<RemoteRunnable
112-
runnableDebuggingMode = "2"
113-
BundleIdentifier = "com.apple.Carousel"
114-
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
109+
<BuildableProductRunnable
110+
runnableDebuggingMode = "0">
115111
<BuildableReference
116112
BuildableIdentifier = "primary"
117113
BlueprintIdentifier = "43A943711B926B7B0051FA24"
118114
BuildableName = "WatchApp.app"
119115
BlueprintName = "WatchApp"
120116
ReferencedContainer = "container:Loop.xcodeproj">
121117
</BuildableReference>
122-
</RemoteRunnable>
123-
<MacroExpansion>
124-
<BuildableReference
125-
BuildableIdentifier = "primary"
126-
BlueprintIdentifier = "43A943711B926B7B0051FA24"
127-
BuildableName = "WatchApp.app"
128-
BlueprintName = "WatchApp"
129-
ReferencedContainer = "container:Loop.xcodeproj">
130-
</BuildableReference>
131-
</MacroExpansion>
118+
</BuildableProductRunnable>
132119
</ProfileAction>
133120
<AnalyzeAction
134121
buildConfiguration = "Debug">

Loop/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
228228
{
229229
deviceDataManager?.analyticsServicesManager.didRetryBolus()
230230

231-
deviceDataManager?.enactBolus(units: units, at: startDate) { (_) in
231+
deviceDataManager?.enactBolus(units: units, automatic: false) { (_) in
232232
completionHandler()
233233
}
234234
return

Loop/Extensions/DeviceDataManager+BolusEntryViewModelDelegate.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ extension DeviceDataManager: BolusEntryViewModelDelegate, LoggedDoseViewModelDel
3232
loopManager.storeBolusDosingDecision(bolusDosingDecision, withDate: date)
3333
}
3434

35-
/// func enactBolus(units: Double, at startDate: Date, completion: @escaping (_ error: Error?) -> Void)
36-
/// is already implemented in DeviceDataManager
37-
3835
func getGlucoseSamples(start: Date?, end: Date?, completion: @escaping (Swift.Result<[StoredGlucoseSample], Error>) -> Void) {
3936
glucoseStore.getGlucoseSamples(start: start, end: end, completion: completion)
4037
}

Loop/Extensions/DeviceDataManager+SimpleBolusViewModelDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ extension DeviceDataManager: SimpleBolusViewModelDelegate {
2222
}
2323
}
2424

25-
func enactBolus(units: Double, at startDate: Date) {
26-
enactBolus(units: units, at: startDate) { (_) in }
25+
func enactBolus(units: Double, automatic: Bool) {
26+
enactBolus(units: units, automatic: automatic) { (_) in }
2727
}
2828

2929
func computeSimpleBolusRecommendation(at date: Date, mealCarbs: HKQuantity?, manualGlucose: HKQuantity?) -> BolusDosingDecision? {

Loop/Extensions/DoseStore+SimulatedCoreData.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ fileprivate extension PersistedPumpEvent {
191191
raw: Data(UUID().uuidString.utf8),
192192
title: UUID().uuidString,
193193
type: type,
194-
isMutable: false)
194+
isMutable: false,
195+
automatic: nil)
195196
}
196197

197198
private static func simulated(dose: DoseEntry) -> PersistedPumpEvent {
@@ -203,6 +204,7 @@ fileprivate extension PersistedPumpEvent {
203204
raw: Data(UUID().uuidString.utf8),
204205
title: String(describing: dose),
205206
type: dose.type.pumpEventType!,
206-
isMutable: false)
207+
isMutable: false,
208+
automatic: nil)
207209
}
208210
}

Loop/Managers/DeviceDataManager.swift

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -580,23 +580,19 @@ private extension DeviceDataManager {
580580

581581
// MARK: - Client API
582582
extension DeviceDataManager {
583-
func enactBolus(units: Double, at startDate: Date = Date(), completion: @escaping (_ error: Error?) -> Void = { _ in }) {
583+
func enactBolus(units: Double, automatic: Bool, completion: @escaping (_ error: Error?) -> Void = { _ in }) {
584584
guard let pumpManager = pumpManager else {
585585
completion(LoopError.configurationError(.pumpManager))
586586
return
587587
}
588588

589589
self.loopManager.addRequestedBolus(DoseEntry(type: .bolus, startDate: Date(), value: units, unit: .units), completion: nil)
590-
pumpManager.enactBolus(units: units, at: startDate) { (result) in
590+
pumpManager.enactBolus(units: units, automatic: automatic) { (result) in
591591
switch result {
592592
case .failure(let error):
593593
self.log.error("%{public}@", String(describing: error))
594-
switch error {
595-
case .uncertainDelivery:
596-
// Do not generate notification on uncertain delivery error
597-
break
598-
default:
599-
NotificationManager.sendBolusFailureNotification(for: error, units: units, at: startDate)
594+
if case .uncertainDelivery = error, !automatic {
595+
NotificationManager.sendBolusFailureNotification(for: error, units: units, at: Date())
600596
}
601597
self.loopManager.bolusRequestFailed(error) {
602598
completion(error)
@@ -1147,7 +1143,7 @@ extension DeviceDataManager: LoopDataManagerDelegate {
11471143
if automaticDose.recommendation.bolusUnits > 0 {
11481144
self.log.default("LoopManager did recommend bolus dose")
11491145
doseDispatchGroup.enter()
1150-
pumpManager.enactBolus(units: automaticDose.recommendation.bolusUnits, at: Date()) { (result) in
1146+
pumpManager.enactBolus(units: automaticDose.recommendation.bolusUnits, automatic: true) { (result) in
11511147
switch result {
11521148
case .failure(let error):
11531149
bolusError = error

Loop/Managers/WatchDataManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ final class WatchDataManager: NSObject {
366366
return
367367
}
368368

369-
deviceManager.enactBolus(units: bolus.value, at: bolus.startDate) { (error) in
369+
deviceManager.enactBolus(units: bolus.value, automatic: true) { (error) in
370370
if error == nil {
371371
self.deviceManager.analyticsServicesManager.didSetBolusFromWatch(bolus.value)
372372
}

0 commit comments

Comments
 (0)