From d72d60e1bd1a78292cd4368690db0e2eee4273a3 Mon Sep 17 00:00:00 2001 From: Corey Baker Date: Sat, 22 Feb 2025 17:05:24 -0800 Subject: [PATCH 1/5] fix: Query HealthKitSamples over specified date interval --- ...thKitPassthroughStore+EventUtilities.swift | 4 +- ...stHealthKitPassthroughStore+Outcomes.swift | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CareKitStore/CareKitStore/HealthKit/OCKHealthKitPassthroughStore+EventUtilities.swift b/CareKitStore/CareKitStore/HealthKit/OCKHealthKitPassthroughStore+EventUtilities.swift index 726e4f47e..e01e13935 100644 --- a/CareKitStore/CareKitStore/HealthKit/OCKHealthKitPassthroughStore+EventUtilities.swift +++ b/CareKitStore/CareKitStore/HealthKit/OCKHealthKitPassthroughStore+EventUtilities.swift @@ -565,7 +565,9 @@ extension OCKHealthKitPassthroughStore { func makeTaskQuery(from outcomeQuery: OCKOutcomeQuery) -> OCKTaskQuery { - let dateInterval = Calendar.current.dateInterval(of: .day, for: Date())! + // Search over the interval provided by OCKOutcomeQuery if present + // or else constrain sample query over the current day. + let dateInterval = outcomeQuery.dateInterval ?? Calendar.current.dateInterval(of: .day, for: Date())! var taskQuery = OCKTaskQuery(dateInterval: dateInterval) taskQuery.ids = outcomeQuery.taskIDs diff --git a/CareKitStore/CareKitStoreTests/OCKHealthKitStore/TestHealthKitPassthroughStore+Outcomes.swift b/CareKitStore/CareKitStoreTests/OCKHealthKitStore/TestHealthKitPassthroughStore+Outcomes.swift index d4c3d4b5b..e39cdc7e8 100644 --- a/CareKitStore/CareKitStoreTests/OCKHealthKitStore/TestHealthKitPassthroughStore+Outcomes.swift +++ b/CareKitStore/CareKitStoreTests/OCKHealthKitStore/TestHealthKitPassthroughStore+Outcomes.swift @@ -143,6 +143,46 @@ class TestHealthKitPassthroughStoreOutcomes: XCTestCase { try passthroughStore.checkAbilityToDelete(outcomes: outcomes) } + func testTaskQueryDefaultsToCurrentDayDateInterval() async throws { + let outcomeTaskQuery = OCKOutcomeQuery() + let taskQuery = passthroughStore.makeTaskQuery(from: outcomeTaskQuery) + let currentDayDateInterval = Calendar.current.dateInterval(of: .day, for: Date())! + + XCTAssertEqual( + taskQuery.dateInterval?.start, + currentDayDateInterval.start + ) + XCTAssertEqual( + taskQuery.dateInterval?.end, + currentDayDateInterval.end + ) + } + + func testTaskQueryBecomesOutcomeQueryDateInterval() async throws { + let yesterday = Calendar.current.date( + byAdding: .day, + value: -1, + to: Date() + )! + let yesterdayDateInterval = Calendar.current.dateInterval( + of: .day, + for: yesterday + )! + let outcomeTaskQuery = OCKOutcomeQuery( + dateInterval: yesterdayDateInterval + ) + let taskQuery = passthroughStore.makeTaskQuery(from: outcomeTaskQuery) + + XCTAssertEqual( + taskQuery.dateInterval?.start, + yesterdayDateInterval.start + ) + XCTAssertEqual( + taskQuery.dateInterval?.end, + yesterdayDateInterval.end + ) + } + // MARK: - Utilities private func makeStepsTask() -> OCKHealthKitTask { From 07be2c49100ad65680a200f46b05607819537e33 Mon Sep 17 00:00:00 2001 From: Corey Date: Sat, 22 Feb 2025 17:12:45 -0800 Subject: [PATCH 2/5] Bump Xcode --- .github/workflows/swift.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 7cd4883e5..fa6e1bdeb 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -10,12 +10,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -jobs: +jobs: test: - runs-on: macos-14 + runs-on: macos-15 strategy: matrix: - destination: ['platform=iOS\ Simulator,OS=18.2,name=iPhone\ 15\ Pro\ Max', 'platform=watchOS\ Simulator,OS=11.2,name=Apple\ Watch\ Series\ 7\ \(45mm\)', 'platform=macOS CODE_SIGN_IDENTITY=""'] + destination: ['platform=iOS\ Simulator,OS=18.2,name=iPhone\ 16\ Pro\ Max', 'platform=watchOS\ Simulator,OS=11.2,name=Apple\ Watch\ Series\ 10\ \(45mm\)', 'platform=macOS CODE_SIGN_IDENTITY=""'] scheme: ['CareKit', 'CareKitStore', 'CareKitUI', 'CareKitFHIR'] exclude: - destination: 'platform=macOS' From a968764e055ad24a988194dd49206fd1759fae2c Mon Sep 17 00:00:00 2001 From: Corey Date: Sat, 22 Feb 2025 17:13:44 -0800 Subject: [PATCH 3/5] nits --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index fa6e1bdeb..5506c436f 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -19,9 +19,9 @@ jobs: scheme: ['CareKit', 'CareKitStore', 'CareKitUI', 'CareKitFHIR'] exclude: - destination: 'platform=macOS' - scheme: 'CareKit' + scheme: 'CareKit' - destination: 'platform=macOS' - scheme: 'CareKitUI' + scheme: 'CareKitUI' steps: - uses: actions/checkout@v4 - name: Set Xcode Version From da91b5acc34604bf2cdbf9e46f6aab514da7afc9 Mon Sep 17 00:00:00 2001 From: Corey Date: Sat, 22 Feb 2025 17:20:34 -0800 Subject: [PATCH 4/5] Update swift.yml --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 5506c436f..d0a991ac6 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -27,4 +27,4 @@ jobs: - name: Set Xcode Version run: sudo xcode-select -s /Applications/Xcode_16.2.app - name: Build - run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -verbose -workspace CKWorkspace.xcworkspace -scheme ${{ matrix.scheme }} -destination ${{ matrix.destination }} build test | xcpretty + run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -verbose -workspace CKWorkspace.xcworkspace -scheme ${{ matrix.scheme }} -destination ${{ matrix.destination }} build test 2>&1 | xcbeautify --renderer github-actions From 43f525c7914009c6604d8a06cde44ed4e6219fab Mon Sep 17 00:00:00 2001 From: Corey Date: Sat, 22 Feb 2025 17:34:04 -0800 Subject: [PATCH 5/5] Update swift.yml --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index d0a991ac6..fb0708d6a 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -15,7 +15,7 @@ jobs: runs-on: macos-15 strategy: matrix: - destination: ['platform=iOS\ Simulator,OS=18.2,name=iPhone\ 16\ Pro\ Max', 'platform=watchOS\ Simulator,OS=11.2,name=Apple\ Watch\ Series\ 10\ \(45mm\)', 'platform=macOS CODE_SIGN_IDENTITY=""'] + destination: ['platform=iOS\ Simulator,OS=18.2,name=iPhone\ 16\ Pro\ Max', 'platform=watchOS\ Simulator,OS=11.2,name=Apple\ Watch\ Series\ 10\ \(46mm\)', 'platform=macOS CODE_SIGN_IDENTITY=""'] scheme: ['CareKit', 'CareKitStore', 'CareKitUI', 'CareKitFHIR'] exclude: - destination: 'platform=macOS'