mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
feat(workouts): show fitness, fatigue and form from the stored training impulse
The first page of the workout list now carries the fitness-fatigue model over the day-total heart-rate impulse the nightly strain run already stores: fitness as the 42-day and fatigue as the 7-day exponentially weighted average, form as their difference. A day without a stored impulse counts as rest. It needs 28 days and three training days, flags the first six weeks as warming up, and reads in the person's own units only. The workouts page shows the three figures above the list.
This commit is contained in:
1 parent
5c64192afc
commit
9be720146c
19 files changed
+651
-1
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import type { TrainingLoad } from "@/lib/insights/training-load";
|
||||
import { useMemo } from "react";
|
||||
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
|
||||
|
||||
@@ -55,6 +56,8 @@ export interface WorkoutListMeta {
|
||||
export interface WorkoutListPayload {
|
||||
workouts: WorkoutListEntry[];
|
||||
meta: WorkoutListMeta;
|
||||
/** v1.44 — first page only; see `GET /api/workouts`. */
|
||||
trainingLoad?: TrainingLoad;
|
||||
}
|
||||
|
||||
export interface UseWorkoutsOptions {
|
||||
@@ -179,6 +182,8 @@ export interface UseInfiniteWorkoutsResult {
|
||||
total: number;
|
||||
isLoading: boolean;
|
||||
isEmpty: boolean;
|
||||
/** v1.44 — fitness, fatigue and form, from the first page. */
|
||||
trainingLoad: TrainingLoad | undefined;
|
||||
error: Error | null;
|
||||
/** True when the first page failed and there is no history to preserve. */
|
||||
isError: boolean;
|
||||
@@ -218,6 +223,7 @@ export function useInfiniteWorkouts(
|
||||
[pages],
|
||||
);
|
||||
const total = query.data?.pages[0]?.meta.total ?? 0;
|
||||
const trainingLoad = query.data?.pages[0]?.trainingLoad;
|
||||
const isEmpty =
|
||||
Boolean(isAuthenticated) &&
|
||||
query.data !== undefined &&
|
||||
@@ -228,6 +234,7 @@ export function useInfiniteWorkouts(
|
||||
total,
|
||||
isLoading: query.isLoading,
|
||||
isEmpty,
|
||||
trainingLoad,
|
||||
error: query.error as Error | null,
|
||||
isError: query.isError && query.data === undefined,
|
||||
isFetchNextPageError: query.isFetchNextPageError,
|
||||
|
||||
Reference in new issue
Block a user