Skip to content

Commit 39a237c

Browse files
authored
Google Health: adjusting dailyRollUp method (#21825)
1 parent 9829438 commit 39a237c

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

components/google_health/actions/get-daily-activity-summary/get-daily-activity-summary.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default {
3030
key: "google_health-get-daily-activity-summary",
3131
name: "Get Daily Activity Summary",
3232
description: "Get a full day of activity at once: steps, distance, calories, active minutes by intensity, active zone minutes by heart rate zone, and floors. The right tool when the user wants an overall picture of a day rather than one metric — use **Get Daily Step Count** for steps alone or **Get Heart Rate** for heart rate detail. The range is inclusive and capped at **14 days** (calories and active minutes impose that limit on the aggregation). Example: startDate=\"2026-08-24\" → `days: [{ date, steps: 8432, distanceKm: 6.1, totalCalories: 2380, activeCalories: 620, activeMinutes: { light, moderate, vigorous, total }, activeZoneMinutes: { fatBurn, cardio, peak, total }, floors: 12 }]`. Set dataSourceFamily=\"google-wearables\" to exclude manually logged activity. A `null` metric means that one metric did not sync for that day and says nothing about the rest of the day — a day can carry real steps alongside a `null` `distanceKm`, so do not report the whole day as empty. An empty `days` array is the separate case where no activity data synced at all for the range. Never report either as zero. The API has no concept of daily goals, so no targets are returned. [See the documentation](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/dailyRollUp)",
33-
version: "0.0.1",
33+
version: "0.0.2",
3434
type: "action",
3535
annotations: {
3636
destructiveHint: false,

components/google_health/actions/get-daily-steps/get-daily-steps.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
key: "google_health-get-daily-steps",
1212
name: "Get Daily Step Count",
1313
description: "Get the user's total step count per day — the tool for any \"how many steps\" question. Returns one pre-aggregated total per day, not raw samples. Use **Get Daily Activity Summary** instead when distance, calories, active minutes, or floors are wanted alongside steps. The range is inclusive and capped at 90 days, because these totals are server-aggregated. Example: startDate=\"2026-08-17\", endDate=\"2026-08-23\" → `days: [{ date, steps: 8432 }, ...]` plus `totalSteps`, `averageSteps`, `daysRequested` and `daysWithData`. Set dataSourceFamily=\"google-wearables\" to count only tracker-recorded steps, excluding manual entries. Days the tracker never reported are omitted from `days` entirely, so `daysWithData` can be lower than `daysRequested` and `averageSteps` is the mean over `daysWithData`. An empty `days` array means nothing synced, not zero steps — `totalSteps` and `averageSteps` are `null` in that case rather than 0. [See the documentation](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/dailyRollUp)",
14-
version: "0.0.1",
14+
version: "0.0.2",
1515
type: "action",
1616
annotations: {
1717
destructiveHint: false,

components/google_health/actions/get-nutrition-and-hydration/get-nutrition-and-hydration.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
key: "google_health-get-nutrition-and-hydration",
2929
name: "Get Nutrition and Hydration Logs",
3030
description: "Get the user's logged food and water intake, with aggregate calorie, macro and water totals. Example: startDate=\"2026-08-24\" → `entries: [{ time, foodDisplayName: \"Greek yogurt\", mealType: \"BREAKFAST\", calories: 180, totalFatG: 4.5, totalCarbohydrateG: 9 }]`, `hydration: [{ time, milliliters: 500, liters: 0.5, flOz: 16.9 }]`, and `totals`. `totals` is **one object covering the whole requested range, not per-day figures** — call a single day at a time if daily breakdowns are wanted. Entries have no date-range limit, but `totals` are server-aggregated and cap the range at 90 days — set includeTotals=false to read entries over a longer span, which makes `totals` `null`. At most **1000 food entries and 1000 hydration entries** come back per call (five pages of 200); `truncated: true` means there were more, so check it before treating the entry list as complete and narrow the range if it is set. Only food the user **logged manually** appears here; nothing is inferred from activity, so an empty result means nothing was logged, not that nothing was eaten. [See the documentation](https://developers.google.com/health/data-types/nutrition)",
31-
version: "0.0.1",
31+
version: "0.0.2",
3232
type: "action",
3333
annotations: {
3434
destructiveHint: false,

components/google_health/google_health.app.mjs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
buildTimeFilter,
1212
civilInterval,
1313
dataSourceFamilyPath,
14+
daysBetween,
1415
durationToSeconds,
1516
} from "./common/utils.mjs";
1617

@@ -210,10 +211,14 @@ export default {
210211
* boundaries are the user's own local midnights, so no timezone lookup is
211212
* needed anywhere in this path.
212213
*
213-
* `pageSize` is pinned to the API maximum because `DailyRollUpDataPointsResponse`
214-
* carries no `nextPageToken`: if the server ever returned a partial set
215-
* there would be no way to detect it. One window per day against a 90-day
216-
* ceiling means the real ask never approaches the cap.
214+
* `pageSize` must cover the requested range exactly. `DailyRollUpDataPointsResponse`
215+
* carries no `nextPageToken`, so a page smaller than the range would be
216+
* silently truncated with no way to detect it — but a page larger than the
217+
* range is rejected outright: the server validates `windowSizeDays * pageSize`
218+
* as a *duration* against the data type's range cap (90 days, 14 for the
219+
* heart-rate family), so an oversized page 400s even for a single day.
220+
* `resolveRange` has already refused anything over that cap, so sizing the
221+
* page to the range keeps it under the ceiling by construction.
217222
*/
218223
async dailyRollUp({
219224
$,
@@ -224,13 +229,16 @@ export default {
224229
windowSizeDays = 1,
225230
} = {}) {
226231
const familyPath = dataSourceFamilyPath(dataSourceFamily);
232+
const pageSize = Math.ceil(
233+
daysBetween(startDate, endExclusive) / windowSizeDays,
234+
);
227235
const response = await this.dailyRollUpDataPoints({
228236
$,
229237
dataType,
230238
data: {
231239
range: civilInterval(startDate, endExclusive),
232240
windowSizeDays,
233-
pageSize: 10000,
241+
pageSize,
234242
...familyPath
235243
? {
236244
dataSourceFamily: familyPath,

components/google_health/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_health",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Pipedream Google Health Components",
55
"main": "google_health.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)