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
Session sheet: whole sets per muscle instead of 1/11.2 (#670)
Duarte Santosc5bff089648f
diff --git a/frontend/src/components/SessionMuscles.jsx b/frontend/src/components/SessionMuscles.jsxindex 29b13220f..d49af20d9 100644--- a/frontend/src/components/SessionMuscles.jsx+++ b/frontend/src/components/SessionMuscles.jsx@@ -34,7 +34,10 @@ export function SessionMapButton({ entries, body }) {</button>}-const r1 = v => Math.round(v * 10) / 10+// A secondary muscle counts as part of a set (bench is 0.4 of a set for the shoulders), which is+// right for the bar but reads odd as "1/11.2". The numbers say whole sets; a little that would+// round to nothing says "<1", so a muscle on the list never reads as 0 planned.+const sets = v => (v > 0 && v < 0.5 ? '<1' : fmtNum(Math.round(v)))const ROWS = 6// The sheet reads the live session itself, so a set ticked behind it (the watch, another tab)@@ -58,13 +61,13 @@ export function SessionMuscles({ close }) {<span className="hm-c l4" />{t('Already worked')}<span className="hm-c l1" />{t('Still to come')}</div>{(all ? muscles : muscles.slice(0, ROWS)).map(m => {- const d = r1(done[m] || 0)- const p = r1(planned[m])+ const d = done[m] || 0+ const p = planned[m]return <div className="mrow" key={m} data-muscle-session={m}><span className="nm">{t(MUSCLE_NAME[m])}</span><span className="bar"><i style={{ width: Math.round(Math.min(d / p, 1) * 100) + '%' }} /></span>- <span className="v sess" aria-label={`${t('Completed')} ${t('{0} sets', fmtNum(d))} · ${t('Planned')} ${t('{0} sets', fmtNum(p))}`}>- {fmtNum(d)}/{fmtNum(p)}+ <span className="v sess" aria-label={`${t('Completed')} ${t('{0} sets', sets(d))} · ${t('Planned')} ${t('{0} sets', sets(p))}`}>+ {sets(d)}/{sets(p)}</span></div>})}diff --git a/frontend/src/views/Workout.muscle-map.test.jsx b/frontend/src/views/Workout.muscle-map.test.jsxindex 59f9c1a1a..3e5834375 100644--- a/frontend/src/views/Workout.muscle-map.test.jsx+++ b/frontend/src/views/Workout.muscle-map.test.jsx@@ -117,13 +117,26 @@ describe('Session muscles sheet (#670)', () => {const rows = () => [...container.querySelectorAll('[data-muscle-session]')]expect(rows()[0].dataset.muscleSession).toBe(CHEST)const w = musclesOf(EXIDX[BENCH])[CHEST]- const r1 = v => String(Math.round(v * 10) / 10)+ const r = v => String(Math.round(v))const value = m => container.querySelector(`[data-muscle-session="${m}"] .v`).textContent- expect(value(CHEST)).toBe(`${r1(w)}/${r1(w * 3)}`)+ expect(value(CHEST)).toBe(`${r(w)}/${r(w * 3)}`)expect(value(QUADS)).toMatch(/^0\//)edit(s => { s.active.entries[1].sets[0].done = true })expect(value(QUADS)).not.toMatch(/^0\//)expect(container.textContent).toContain('Already worked')expect(container.textContent).toContain('Still to come')})++ it('shows whole sets, not the fractions a secondary muscle adds up to', () => {+ // Bench is 0.4 of a set for the shoulders: one ticked of three is 0.4/1.2, a single set 0/0.4.+ const shoulder = Object.entries(musclesOf(EXIDX[BENCH])).find(([, v]) => v > 0 && v < 0.5)[0]+ setActive([entry(BENCH, [row(true), row(), row()])])+ render(<SessionMuscles close={() => {}} />)+ const value = m => container.querySelector(`[data-muscle-session="${m}"] .v`).textContent+ expect(value(shoulder)).toBe('<1/1')+ for (const el of container.querySelectorAll('[data-muscle-session] .v')) expect(el.textContent).not.toMatch(/\./)+ edit(s => { s.active.entries[0].sets = [row()] })+ expect(value(shoulder)).toBe('0/<1')+ expect(value(CHEST)).toBe('0/1')+ })})