Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific Upload Error Handling #51

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
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
40 changes: 27 additions & 13 deletions PAWS/PAWSStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,39 @@

private func upload(electrocardiogram: HKElectrocardiogram) async {
var supplementalMetrics: [HKSample] = []
var precedingPulseRates: [HKQuantitySample] = []
var precedingPhysicalEffort: [HKQuantitySample] = []
var precedingStepCount: [HKQuantitySample] = []
var precedingActiveEnergy: [HKQuantitySample] = []
var precedingVo2Max: HKQuantitySample?

Check warning on line 88 in PAWS/PAWSStandard.swift

View check run for this annotation

Codecov / codecov/patch

PAWS/PAWSStandard.swift#L84-L88

Added lines #L84 - L88 were not covered by tests

do {
try await upload(sample: electrocardiogram)

supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingPulseRates)
supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingPhysicalEffort)
supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingStepCount)
supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingActiveEnergy)

if let precedingVo2Max = try await electrocardiogram.precedingVo2Max {
supplementalMetrics.append(precedingVo2Max)
}

for supplementalMetric in supplementalMetrics {
try await upload(sample: supplementalMetric)
}
precedingPulseRates = try await electrocardiogram.precedingPulseRates
precedingPhysicalEffort = try await electrocardiogram.precedingPhysicalEffort
precedingStepCount = try await electrocardiogram.precedingStepCount
precedingActiveEnergy = try await electrocardiogram.precedingActiveEnergy
precedingVo2Max = try await electrocardiogram.precedingVo2Max

Check warning on line 96 in PAWS/PAWSStandard.swift

View check run for this annotation

Codecov / codecov/patch

PAWS/PAWSStandard.swift#L92-L96

Added lines #L92 - L96 were not covered by tests
MatthewTurk247 marked this conversation as resolved.
Show resolved Hide resolved
} catch {
logger.log("Could not access HealthKit sample: \(error)")
}

supplementalMetrics.append(contentsOf: precedingPulseRates)
supplementalMetrics.append(contentsOf: precedingPhysicalEffort)
supplementalMetrics.append(contentsOf: precedingStepCount)
supplementalMetrics.append(contentsOf: precedingActiveEnergy)

if let precedingVo2Max {
supplementalMetrics.append(precedingVo2Max)
}

for supplementalMetric in supplementalMetrics {
do {
try await upload(sample: supplementalMetric)
} catch {
logger.log("Could not upload \(supplementalMetric.sampleType): \(error)")
}
}

Check warning on line 116 in PAWS/PAWSStandard.swift

View check run for this annotation

Codecov / codecov/patch

PAWS/PAWSStandard.swift#L100-L116

Added lines #L100 - L116 were not covered by tests
}

private func updateElectrocardiogram(basedOn categorySample: HKCategorySample) async {
Expand Down
Loading