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

Incorporate sleep data into complication user info transfer calculations #1217

Merged
merged 23 commits into from
Feb 4, 2020
Merged
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
774a272
Resolve conflicts
novalegra Dec 22, 2019
6849b3c
Actually resolve them :-)
novalegra Dec 22, 2019
ab440e9
Add what I have
novalegra Dec 23, 2019
c1512d4
Add sleep permission
novalegra Dec 25, 2019
ee2227a
Refine complication math
novalegra Dec 25, 2019
0658c47
Improvements to complication-refresh code
novalegra Dec 27, 2019
f68e6ef
Merge remote-tracking branch 'upstream/dev' into update-complications
novalegra Dec 27, 2019
e503af4
Update to match dev
novalegra Dec 27, 2019
2e742d7
Make cartfile accurate
novalegra Dec 27, 2019
53c98a8
Add newline
novalegra Dec 27, 2019
a65f586
TimeInterval -> Date
novalegra Dec 28, 2019
cc17049
Ensure last update time is updated in case of failure
novalegra Dec 28, 2019
28795e5
Remove print statement
novalegra Dec 29, 2019
ec14d2e
Changes based on review
novalegra Dec 30, 2019
e70a89e
More changes in response to review
novalegra Dec 31, 2019
fbaa204
Merge branch 'aq/update-complications' of https://github.com/novalegr…
ps2 Jan 26, 2020
f83217a
Avoid crash on HKSampleQuery error
ps2 Jan 26, 2020
20bc003
Fix crash due to incorrect error type
novalegra Jan 26, 2020
f71c485
Merge remote-tracking branch 'origin/aq/update-complications' into up…
novalegra Jan 26, 2020
aeb14be
Fix for authorization error
novalegra Jan 27, 2020
ffbaea9
Remove delay to mirror LoopKit
novalegra Jan 28, 2020
975c296
Merge remote-tracking branch 'upstream/dev' into update-complications
novalegra Jan 28, 2020
cc0d636
Update ExponentialInsulinModelPreset.swift
novalegra Jan 28, 2020
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
4 changes: 4 additions & 0 deletions Loop/Managers/SleepStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import HealthKit
import os.log

enum SleepStoreResult<T> {
case success(T)
Expand All @@ -24,6 +25,8 @@ enum SleepStoreError: Error {
class SleepStore {
var healthStore: HKHealthStore

private let log = OSLog(category: "SleepStore")

public init(
healthStore: HKHealthStore
) {
Expand Down Expand Up @@ -69,6 +72,7 @@ class SleepStore {
let query = HKSampleQuery(sampleType: sleepType, predicate: predicate, limit: sampleLimit, sortDescriptors: [sortByDate]) { (query, samples, error) in

if let error = error {
self.log.error("Error fetching sleep data: %{public}@", String(describing: error))
completion(.failure(SleepStoreError.queryError(error.localizedDescription)))
} else if let samples = samples as? [HKCategorySample] {
guard !samples.isEmpty else {
Expand Down