mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
Add a WATER_INTAKE measurement type and a per-user daily goal so the Insights overview can track water intake against a goal ring. Logging rides the existing measurements create path (type WATER_INTAKE, unit ml, summed cumulatively); GET/PATCH /api/hydration read the day total and own the goal. The goal-ring math (empty / partial / met / exceeded) lives in a pure helper, free of Prisma and React, and is unit-tested in isolation. Wire the new type through the measurement enum, value ranges, cumulative HealthKit handling, categories, display transform, list metadata, record direction, and the chartable-token allowlist. The HealthKit DietaryWater import stays on the nutrition hold, so the type carries no import mapping by design. Document GET/PATCH /api/hydration in the OpenAPI contract.
11 lines
447 B
TypeScript
11 lines
447 B
TypeScript
/**
|
|
* Query keys — hydration tree: today's water-intake total vs the daily goal
|
|
* (`/api/hydration`). Part of the centralized factory; aggregated in
|
|
* `./index.ts`. A `WATER_INTAKE` measurement write busts this key through the
|
|
* `measurementDependentKeys` bundle so the goal ring refreshes in lockstep.
|
|
*/
|
|
export const hydrationKeys = {
|
|
hydration: () => ["hydration"] as const,
|
|
hydrationToday: () => ["hydration", "today"] as const,
|
|
};
|