-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add aggregate group methods (#172)
- Loading branch information
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,38 @@ | ||
--- | ||
title: aggregateGroupByDuration | ||
--- | ||
|
||
# `aggregateGroupByDuration` | ||
|
||
Reads aggregated group result by Duration according to requested read criteria. `timeRangeSlicer` needs to be specified for the Duration type (`MILLIS' | 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS`) and length. Some record types do not support aggregation. | ||
|
||
# Method | ||
|
||
```ts | ||
aggregateGroupByDuration<T extends AggregateResultRecordType>( | ||
request: AggregateGroupByDurationRequest<T> | ||
): Promise<AggregationGroupResult<T>[]> | ||
``` | ||
|
||
# Example | ||
|
||
```ts | ||
import { aggregateGroupByDuration } from 'react-native-health-connect'; | ||
|
||
const aggregateSampleData = () => { | ||
aggregateGroupByDuration({ | ||
recordType: 'Steps', | ||
timeRangeFilter: { | ||
operator: 'between', | ||
startTime: '2024-10-04T15:00:00Z', | ||
endTime: '2024-10-12T14:57:39.714Z', | ||
}, | ||
timeRangeSlicer: { | ||
duration: 'DAYS', | ||
length: 2, | ||
}, | ||
}).then((result) => { | ||
console.log('Aggregated Group by Duration: ', { result }); // Aggregated record: {"result": [{"endTime": "2024-10-06T15:00:00Z", "startTime": "2024-10-04T15:00:00Z", "zoneOffset": "+09:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 3000}}, {"endTime": "2024-10-08T15:00:00Z", "startTime": "2024-10-06T15:00:00Z", "zoneOffset": "+09:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 7000}}, {"endTime": "2024-10-10T15:00:00Z", "startTime": "2024-10-08T15:00:00Z", "zoneOffset": "+09:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 11000}}, {"endTime": "2024-10-12T14:57:39.714Z", "startTime": "2024-10-10T15:00:00Z", "zoneOffset": "+09:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 7000}}]} | ||
}); | ||
}; | ||
``` |
This file contains 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,38 @@ | ||
--- | ||
title: aggregateGroupByPeriod | ||
--- | ||
|
||
# `aggregateGroupByPeriod` | ||
|
||
Reads aggregated group result by Period according to requested read criteria. `timeRangeSlicer` needs to be specified for the Period type (`'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'`) and length. `Period` is date-based amount of time as opposed to `Duration`, which is a fixed length of time. Some record types do not support aggregation. | ||
|
||
# Method | ||
|
||
```ts | ||
aggregateGroupByPeriod<T extends AggregateResultRecordType>( | ||
request: AggregateGroupByPeriodRequest<T> | ||
): Promise<AggregationGroupResult<T>[]> | ||
``` | ||
|
||
# Example | ||
|
||
```ts | ||
import { aggregateGroupByPeriod } from 'react-native-health-connect'; | ||
|
||
const aggregateSampleData = () => { | ||
aggregateGroupByPeriod({ | ||
recordType: 'Steps', | ||
timeRangeFilter: { | ||
operator: 'between', | ||
startTime: '2024-09-03T15:00', | ||
endTime: '2024-09-11T10:50:12.182', | ||
}, | ||
timeRangeSlicer: { | ||
period: 'DAYS', | ||
length: 1, | ||
}, | ||
}).then((result) => { | ||
console.log('Aggregated Group by Period: ', { result }); // Aggregated record: {"result": [{"endTime": "2024-09-04T15:00", "startTime": "2024-09-03T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 1000}}, {"endTime": "2024-09-05T15:00", "startTime": "2024-09-04T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 2000}}, {"endTime": "2024-09-06T15:00", "startTime": "2024-09-05T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 3000}}, {"endTime": "2024-09-07T15:00", "startTime": "2024-09-06T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 4000}}, {"endTime": "2024-09-08T15:00", "startTime": "2024-09-07T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 5000}}, {"endTime": "2024-09-09T15:00", "startTime": "2024-09-08T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 6000}}, {"endTime": "2024-09-10T15:00", "startTime": "2024-09-09T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 7000}}, {"endTime": "2024-09-11T10:50:12.182", "startTime": "2024-09-10T15:00", "result": {"dataOrigins": [], "COUNT_TOTAL": 0}}]} | ||
}); | ||
}; | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.