Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
feat(stats): show fatigue percent and recovery forecast on muscle tap
Сергей Горбатенко7305fa8a07e0
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsxindex d7f399fbe..95adeb76b 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -16,7 +16,7 @@ import BodyMap, { BodyMapLegend } from '../components/BodyMap.jsx'import { loadOfWeeklyPlan, loadOfWorkouts, muscleBalanceWindow, rankOf, MUSCLES, MUSCLE_NAME, musclesOf } from '../lib/muscles.js'import { fatigueOf, strengthOf, STRENGTH_FLOOR, LB_TO_KG } from '../lib/recovery.js'import { strengthExerciseRowsForMuscle } from '../lib/strength-exercises.js'-import { fatigueStateOf } from '../lib/recovery-view.js'+import { fatigueStateOf, fatigueRecoveryMs, fmtRecoveryIn } from '../lib/recovery-view.js'import { e1rmSeries, best1RM, formulaOf } from '../lib/onerm.js'import { currentDbLoad, workoutAs } from '../lib/dumbbells.js'import { maxRepsSeries } from '../lib/pyramid.js'@@ -154,6 +154,10 @@ function MuscleBalance({ S }) {return t('Weeks since training: {0}', weeks)}const toggleSel = m => setSel(s => (s === m ? null : m))+ // Selected-muscle detail for the Fatigue view: the same display value that+ // shades the map, as a percentage, plus when it drops back through the bands.+ const selFatigue = sel ? (fatigue[sel] || 0) : 0+ const selRecovery = sel ? fatigueRecoveryMs(selFatigue, sel) : { toRecoveringMs: null, toReadyMs: null }const ws = weekStartOf(S)const currentWeek = weekKey(todayISO(), ws)const selectedWeekDate = new Date(currentWeek + 'T12:00:00')@@ -267,9 +271,13 @@ function MuscleBalance({ S }) {<BodyMap className="tappable hm-fatigue" load={fatigue} thresholds={FATIGUE_LEVELS} body={S.body} selected={sel} onMuscle={toggleSel} /><FatigueLegend /><div className="muted small" style={{ marginTop: 10 }}>{t('Fatigue shows how recently each muscle was trained. High means rest.')}</div>- {sel && <div className="mrow" style={{ borderTop: 'var(--hair) solid var(--sep)', marginTop: 4, paddingTop: 10 }}>- <span className="nm"><b>{t(MUSCLE_NAME[sel])}</b></span>- <span className="v">{fatigueLabel(fatigue[sel])}</span>+ {sel && <div style={{ borderTop: 'var(--hair) solid var(--sep)', marginTop: 4, paddingTop: 10 }}>+ <div className="mrow">+ <span className="nm"><b>{t(MUSCLE_NAME[sel])}</b></span>+ <span className="v">{Math.round(selFatigue * 100)}% · {fatigueLabel(selFatigue)}</span>+ </div>+ {selRecovery.toRecoveringMs != null && <div className="small dim">{t('Recovering {0}', fmtRecoveryIn(selRecovery.toRecoveringMs))}</div>}+ {selRecovery.toReadyMs != null && <div className="small dim">{t('Ready {0}', fmtRecoveryIn(selRecovery.toReadyMs))}</div>}</div>}</> : <><h2>{t('Strength')}</h2>diff --git a/frontend/src/views/Stats.recovery.test.jsx b/frontend/src/views/Stats.recovery.test.jsxindex f7b339b2c..516d78008 100644--- a/frontend/src/views/Stats.recovery.test.jsx+++ b/frontend/src/views/Stats.recovery.test.jsx@@ -279,6 +279,18 @@ describe('Stats muscle recovery view runtime', () => {expect(lastMap().load.chest).toBe(6)})+ it('shows the selected muscle fatigue as a percentage with recovery forecast', async () => {+ await mountStats()+ await click(viewButton('Fatigue'))+ await click(muscleCard().querySelector('[data-muscle="chest"]'))+ const value = lastMap().load.chest+ expect(value).toBeGreaterThan(0.5)+ expect(muscleCard().textContent).toContain(`${Math.round(value * 100)}%`)+ // Fatigued chest drops through both bands, so both forecasts render.+ expect(muscleCard().textContent).toContain('Recovering in')+ expect(muscleCard().textContent).toContain('Ready in')+ })+it('derives a pound-profile bodyweight in kg and passes it into the rendered Fatigue map', async () => {const bodyweightWorkout = workout('bodyweight', BASE_NOW, [entry('0001', [{ done: true, w: 0, r: 10 }]),