-
Notifications
You must be signed in to change notification settings - Fork 2
Migrate some Apple Health daily data providers to V2. #613
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
Open
greinard
wants to merge
1
commit into
main
Choose a base branch
from
v2-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
__tests__/helpers/daily-data-providers/apple-health-blood-glucose.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
| import { sampleEndDate, sampleResult, sampleStartDate, setupAggregateDailyData } from '../../fixtures/daily-data-providers'; | ||
| import appleHealthBloodGlucose from '../../../src/helpers/daily-data-providers/apple-health-blood-glucose'; | ||
|
|
||
| describe('Daily Data Provider - Apple Health Blood Glucose', () => { | ||
| it('Should query for aggregate daily data and return the average values keyed by date.', async () => { | ||
| setupAggregateDailyData('AppleHealth', 'Blood Glucose', sampleStartDate, sampleEndDate, 'avg', sampleResult); | ||
| expect(await appleHealthBloodGlucose(sampleStartDate, sampleEndDate)).toBe(sampleResult); | ||
| }); | ||
| }); |
45 changes: 16 additions & 29 deletions
45
__tests__/helpers/daily-data-providers/apple-health-heart-rate-range.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
__tests__/helpers/daily-data-providers/apple-health-max-blood-glucose.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
| import { sampleEndDate, sampleResult, sampleStartDate, setupAggregateDailyData } from '../../fixtures/daily-data-providers'; | ||
| import appleHealthMaxBloodGlucose from '../../../src/helpers/daily-data-providers/apple-health-max-blood-glucose'; | ||
|
|
||
| describe('Daily Data Provider - Apple Health Max Blood Glucose', () => { | ||
| it('Should query for aggregate daily data and return the maximum values keyed by date.', async () => { | ||
| setupAggregateDailyData('AppleHealth', 'Blood Glucose', sampleStartDate, sampleEndDate, 'max', sampleResult); | ||
| expect(await appleHealthMaxBloodGlucose(sampleStartDate, sampleEndDate)).toBe(sampleResult); | ||
| }); | ||
| }); |
7 changes: 3 additions & 4 deletions
7
__tests__/helpers/daily-data-providers/apple-health-max-heart-rate.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
| import { sampleDailyData, sampleEndDate, sampleResult, sampleStartDate, setupDailyData, setupMaxValueResult, startDateFunctionEvaluator } from '../../fixtures/daily-data-providers'; | ||
| import { sampleEndDate, sampleResult, sampleStartDate, setupAggregateDailyData } from '../../fixtures/daily-data-providers'; | ||
| import appleHealthMaxHeartRate from '../../../src/helpers/daily-data-providers/apple-health-max-heart-rate'; | ||
|
|
||
| describe('Daily Data Provider - Apple Health Max Heart Rate', () => { | ||
| it('Should query for daily data and build a max value result keyed by start date.', async () => { | ||
| setupDailyData('AppleHealth', 'HourlyMaximumHeartRate', sampleStartDate, sampleEndDate, startDateFunctionEvaluator, sampleDailyData); | ||
| setupMaxValueResult(sampleDailyData, sampleResult); | ||
| it('Should query for aggregate daily data and return the maximum values keyed by date.', async () => { | ||
| setupAggregateDailyData('AppleHealth', 'Hourly Maximum Heart Rate', sampleStartDate, sampleEndDate, 'max', sampleResult); | ||
| expect(await appleHealthMaxHeartRate(sampleStartDate, sampleEndDate)).toBe(sampleResult); | ||
| }); | ||
| }); |
10 changes: 10 additions & 0 deletions
10
__tests__/helpers/daily-data-providers/apple-health-min-blood-glucose.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
| import { sampleEndDate, sampleResult, sampleStartDate, setupAggregateDailyData } from '../../fixtures/daily-data-providers'; | ||
| import appleHealthMinBloodGlucose from '../../../src/helpers/daily-data-providers/apple-health-min-blood-glucose'; | ||
|
|
||
| describe('Daily Data Provider - Apple Health Min Blood Glucose', () => { | ||
| it('Should query for aggregate daily data and return the minimum values keyed by date.', async () => { | ||
| setupAggregateDailyData('AppleHealth', 'Blood Glucose', sampleStartDate, sampleEndDate, 'min', sampleResult); | ||
| expect(await appleHealthMinBloodGlucose(sampleStartDate, sampleEndDate)).toBe(sampleResult); | ||
| }); | ||
| }); |
10 changes: 10 additions & 0 deletions
10
__tests__/helpers/daily-data-providers/apple-health-min-heart-rate.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
| import { sampleEndDate, sampleResult, sampleStartDate, setupAggregateDailyData } from '../../fixtures/daily-data-providers'; | ||
| import appleHealthMinHeartRate from '../../../src/helpers/daily-data-providers/apple-health-min-heart-rate'; | ||
|
|
||
| describe('Daily Data Provider - Apple Health Min Heart Rate', () => { | ||
| it('Should query for aggregate daily data and return the minimum values keyed by date.', async () => { | ||
| setupAggregateDailyData('AppleHealth', 'Hourly Minimum Heart Rate', sampleStartDate, sampleEndDate, 'min', sampleResult); | ||
| expect(await appleHealthMinHeartRate(sampleStartDate, sampleEndDate)).toBe(sampleResult); | ||
| }); | ||
| }); |
10 changes: 5 additions & 5 deletions
10
__tests__/helpers/daily-data-providers/apple-health-mindful-minutes.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
__tests__/helpers/daily-data-providers/apple-health-resting-heart-rate.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
| import { sampleDailyData, sampleEndDate, sampleResult, sampleStartDate, setupAverageValueResult, setupDailyData, startDateFunctionEvaluator } from '../../fixtures/daily-data-providers'; | ||
| import { sampleEndDate, sampleResult, sampleStartDate, setupAggregateDailyData } from '../../fixtures/daily-data-providers'; | ||
| import appleHealthRestingHeartRate from '../../../src/helpers/daily-data-providers/apple-health-resting-heart-rate'; | ||
|
|
||
| describe('Daily Data Provider - Apple Health Resting Heart Rate', () => { | ||
| it('Should query for daily data and build an average value result keyed by start date.', async () => { | ||
| setupDailyData('AppleHealth', 'RestingHeartRate', sampleStartDate, sampleEndDate, startDateFunctionEvaluator, sampleDailyData); | ||
| setupAverageValueResult(sampleDailyData, sampleResult); | ||
| it('Should query for aggregate daily data and return the average values keyed by date.', async () => { | ||
| setupAggregateDailyData('AppleHealth', 'Resting Heart Rate', sampleStartDate, sampleEndDate, 'avg', sampleResult); | ||
| expect(await appleHealthRestingHeartRate(sampleStartDate, sampleEndDate)).toBe(sampleResult); | ||
| }); | ||
| }); | ||
24 changes: 0 additions & 24 deletions
24
__tests__/helpers/daily-data-providers/apple-health-sleep-v2.test.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throughout this are data type names like "Resting Heart Rate". We have what seems to be a mapping for this in the tables like
RESTING_HEART_RATE_SOURCES. It seems like it would be more clear if we used that, so instead of a literal string we have something likeRESTING_HEART_RATE_SOURCES[AppleHealth].This would apply both to the tests and to the providers themselves. So something like:
return queryAggregateDailyData('AppleHealth', 'Hourly Steps', startDate, endDate, 'sum');would become:
return queryAggregateDailyData('AppleHealth', STEPS_SOURCES[AppleHealth], startDate, endDate, 'sum');