Skip to content

Commit cf728ab

Browse files
author
Rick Pasetto
authored
LOOP-1328: Adds healthKitEligibleDate (#441)
1 parent bd735fa commit cf728ab

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

Common/Models/WatchHistoricalGlucose.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extension WatchHistoricalGlucose: RawRepresentable {
4545
let isDisplayOnlys: [Bool]
4646
let wasUserEntereds: [Bool]
4747
let devices: [Data?]
48+
let healthKitEligibleDates: [Date?]
4849

4950
init(samples: [StoredGlucoseSample]) {
5051
self.uuids = samples.map { $0.uuid }
@@ -57,20 +58,22 @@ extension WatchHistoricalGlucose: RawRepresentable {
5758
self.isDisplayOnlys = samples.map { $0.isDisplayOnly }
5859
self.wasUserEntereds = samples.map { $0.wasUserEntered }
5960
self.devices = samples.map { try? WatchHistoricalGlucose.encoder.encode($0.device) }
61+
self.healthKitEligibleDates = samples.map { $0.healthKitEligibleDate }
6062
}
6163

6264
var samples: [StoredGlucoseSample] {
6365
return (0..<uuids.count).map {
6466
return StoredGlucoseSample(uuid: uuids[$0],
65-
provenanceIdentifier: provenanceIdentifiers[$0],
66-
syncIdentifier: syncIdentifiers[$0],
67-
syncVersion: syncVersions[$0],
68-
startDate: startDates[$0],
69-
quantity: HKQuantity(unit: .milligramsPerDeciliter, doubleValue: quantities[$0]),
70-
trend: trends[$0],
71-
isDisplayOnly: isDisplayOnlys[$0],
72-
wasUserEntered: wasUserEntereds[$0],
73-
device: devices[$0].flatMap { try? HKDevice(from: $0) })
67+
provenanceIdentifier: provenanceIdentifiers[$0],
68+
syncIdentifier: syncIdentifiers[$0],
69+
syncVersion: syncVersions[$0],
70+
startDate: startDates[$0],
71+
quantity: HKQuantity(unit: .milligramsPerDeciliter, doubleValue: quantities[$0]),
72+
trend: trends[$0],
73+
isDisplayOnly: isDisplayOnlys[$0],
74+
wasUserEntered: wasUserEntereds[$0],
75+
device: devices[$0].flatMap { try? HKDevice(from: $0) },
76+
healthKitEligibleDate: healthKitEligibleDates[$0])
7477
}
7578
}
7679
}

LoopTests/Managers/CGMStalenessMonitorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CGMStalenessMonitorTests: XCTestCase {
1818
private var fetchExpectation: XCTestExpectation?
1919

2020
private var storedGlucoseSample: StoredGlucoseSample {
21-
return StoredGlucoseSample(uuid: UUID(), provenanceIdentifier: UUID().uuidString, syncIdentifier: "syncIdentifier", syncVersion: 1, startDate: Date().addingTimeInterval(-.minutes(5)), quantity: HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 120), trend: .flat, isDisplayOnly: false, wasUserEntered: false, device: nil)
21+
return StoredGlucoseSample(uuid: UUID(), provenanceIdentifier: UUID().uuidString, syncIdentifier: "syncIdentifier", syncVersion: 1, startDate: Date().addingTimeInterval(-.minutes(5)), quantity: HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 120), trend: .flat, isDisplayOnly: false, wasUserEntered: false, device: nil, healthKitEligibleDate: nil)
2222
}
2323

2424
private var newGlucoseSample: NewGlucoseSample {

LoopTests/Models/WatchHistoricalGlucoseTest.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class WatchHistoricalGlucoseTests: XCTestCase {
2424
trend: nil,
2525
isDisplayOnly: false,
2626
wasUserEntered: true,
27-
device: device),
27+
device: device,
28+
healthKitEligibleDate: Date(timeIntervalSinceReferenceDate: .hours(100)).addingTimeInterval(.hours(3))),
2829
StoredGlucoseSample(uuid: UUID(),
2930
provenanceIdentifier: UUID().uuidString,
3031
syncIdentifier: UUID().uuidString,
@@ -34,7 +35,8 @@ class WatchHistoricalGlucoseTests: XCTestCase {
3435
trend: .up,
3536
isDisplayOnly: true,
3637
wasUserEntered: false,
37-
device: device),
38+
device: device,
39+
healthKitEligibleDate: nil),
3840
StoredGlucoseSample(uuid: nil,
3941
provenanceIdentifier: UUID().uuidString,
4042
syncIdentifier: nil,
@@ -44,7 +46,8 @@ class WatchHistoricalGlucoseTests: XCTestCase {
4446
trend: .downDownDown,
4547
isDisplayOnly: false,
4648
wasUserEntered: false,
47-
device: nil),
49+
device: nil,
50+
healthKitEligibleDate: nil),
4851
]
4952
}()
5053

0 commit comments

Comments
 (0)