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

docs: add aggregate group methods #172

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 38 additions & 0 deletions docs/docs/api/methods/10-aggregateGroupByDuration.md
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}}]}
});
};
```
38 changes: 38 additions & 0 deletions docs/docs/api/methods/11-aggregateGroupByPeriod.md
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}}]}
});
};
```
Loading