fix(fitbit): wire the activity page-size constant and drop dead exports

Use FITBIT_ACTIVITY_PAGE_SIZE for the sleep and exercise reads instead of a
magic 25, remove the unused FitbitDataTypeKey type, and declare the crosstab
day floors independently so they aren't a duplicate re-export of the influence
floors.
This commit is contained in:
Marc-André Bombeck committed 2026-06-05 01:25:39 +02:00
1 parent 678ee80299
commit 554d97ec95
4 files changed
+15 -10

No files matched your search

-2
View File
@@ -351,8 +351,6 @@ export const FITBIT_DATA_TYPES = {
exercise: { path: "exercise", filter: "exercise", timeField: "interval" },
} as const satisfies Record<string, FitbitDataType>;
export type FitbitDataTypeKey = keyof typeof FITBIT_DATA_TYPES;
/** Google Health `DataPoint` — value object is type-keyed + carries a time anchor. */
export interface FitbitDataPoint {
[key: string]: unknown;
+7 -2
View File
@@ -16,7 +16,12 @@
* A per-data-class 403 soft-skips the resource — the sleep bundle is granted
* independently of activity / metrics in the Google consent flow.
*/
import { FITBIT_DATA_TYPES, fetchDataPoints, mapSleepSession } from "./client";
import {
FITBIT_ACTIVITY_PAGE_SIZE,
FITBIT_DATA_TYPES,
fetchDataPoints,
mapSleepSession,
} from "./client";
import {
getValidToken,
handleCollectionFetchError,
@@ -43,7 +48,7 @@ export async function syncUserSleep(
FITBIT_DATA_TYPES.sleep,
tokenInfo.accessToken,
"fetchSleep",
{ start, pageSize: 25 },
{ start, pageSize: FITBIT_ACTIVITY_PAGE_SIZE },
);
} catch (err) {
return handleCollectionFetchError("fetchSleep", userId, err);
+2 -1
View File
@@ -15,6 +15,7 @@
* granted independently in the Google consent flow.
*/
import {
FITBIT_ACTIVITY_PAGE_SIZE,
FITBIT_DATA_TYPES,
fetchDataPoints,
mapWorkout,
@@ -45,7 +46,7 @@ export async function syncUserWorkout(
FITBIT_DATA_TYPES.exercise,
tokenInfo.accessToken,
"fetchExercise",
{ start, pageSize: 25 },
{ start, pageSize: FITBIT_ACTIVITY_PAGE_SIZE },
);
} catch (err) {
return handleCollectionFetchError("fetchExercise", userId, err);
+6 -5
View File
@@ -724,12 +724,13 @@ export function computeBetterDays(
export const CROSSTAB_FDR_Q = 0.1;
/**
* Per-side day floors for the crosstab — reuse the influence floors so a
* tag needs the same defensible present/absent support before a metric
* delta surfaces.
* Per-side day floors for the crosstab — kept in step with the influence
* floors (`INFLUENCE_MIN_PRESENT_DAYS` / `INFLUENCE_MIN_ABSENT_DAYS`) so a tag
* needs the same defensible present/absent support before a metric delta
* surfaces. Declared independently so the crosstab surface owns its own floor.
*/
export const CROSSTAB_MIN_PRESENT_DAYS = INFLUENCE_MIN_PRESENT_DAYS;
export const CROSSTAB_MIN_ABSENT_DAYS = INFLUENCE_MIN_ABSENT_DAYS;
export const CROSSTAB_MIN_PRESENT_DAYS = 5;
export const CROSSTAB_MIN_ABSENT_DAYS = 5;
/** Max rows surfaced across the whole crosstab so the surface stays scannable. */
export const CROSSTAB_MAX_ROWS = 8;