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
History: rep sets stay rep sets after their exercise moves to Cardio
Duarte Santos67ebfd4d9197
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex b593924ce..21b285250 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -117,6 +117,7 @@ const effortTail = s => {// One-line summary of a logged set. `cfg` carries the mode when the caller has it (a routine// entry or a workout entry); passing an id alone keeps the old body-part behaviour.// `speedUnit` is the profile's (lib/speed.js speedUnitOf); without one a cardio set reads km/h.+const EXPLICIT_MODES = new Set(['reps', 'time', 'cardio'])export function setLabel(id, s, cfg, speedUnit) {// The id is the caller's when the config does not carry one: a freestyle target is built// without it, and modeOf would then fall back to 'reps' and print a run as "0×0".@@ -125,6 +126,10 @@ export function setLabel(id, s, cfg, speedUnit) {// A set saved by an older build carries no target with it; the set's own fields still say what// it was — seconds for a timed set, minutes for cardio — so those are not read back as "0 reps".if (!cfg && !(s.r > 0)) { if (s.min > 0 || s.speed > 0) mode = 'cardio'; else if (s.sec > 0) mode = 'time' }+ // A target with no mode of its own takes it from the exercise, and an exercise can change: a+ // custom one moved to Cardio after months of rep sets read them all as "0 min @ 0 km/h", next+ // to the volume those same sets still count. A set with reps and nothing cardio was a rep set.+ if (!EXPLICIT_MODES.has(cfg?.mode) && mode !== 'reps' && s.r > 0 && !(s.min > 0 || s.speed > 0 || s.sec > 0)) mode = 'reps'if (mode === 'cardio') return `${s.min || 0} min @ ${fmtSpeed(s.speed || 0, speedUnit)}`if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '')const bw = isBw(c)diff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex f5260e50d..179682898 100644--- a/frontend/src/lib/history.test.js+++ b/frontend/src/lib/history.test.js@@ -77,6 +77,17 @@ describe('setLabel', () => {expect(setLabel(CARDIO, { sec: 45, w: 0 }, { mode: 'time' })).toBe('0:45')})+ // QA 1.3.11: a custom exercise moved to Cardio after months of rep sets read its history as+ // "0 min @ 0 km/h" next to the volume those sets still count. A target with no mode of its own+ // follows the set's fields; one that names a mode still decides.+ it('reads a rep set as reps when its exercise has become cardio since', () => {+ expect(setLabel(CARDIO, { w: 50, r: 10 }, { sets: 3, reps: 10, weight: 50, bodyweight: false })).toBe('50×10')+ // no target at all: the catalogue's cardio entry is body weight, so the load reads as added+ expect(setLabel(CARDIO, { w: 50, r: 10 })).toBe('+50 × 10')+ expect(setLabel(CARDIO, { min: 20, speed: 9, r: 0 }, { sets: 1 })).toBe('20 min @ 9 km/h')+ expect(setLabel(CARDIO, { w: 50, r: 10 }, { mode: 'cardio' })).toBe('0 min @ 0 km/h')+ })+it('appends RIR when present, including a valid 0', () => {expect(setLabel(LIFT, { w: 60, r: 10, rir: 2 })).toBe('60×10 (RIR 2)')expect(setLabel(LIFT, { w: 60, r: 10, rir: 1.5 })).toBe('60×10 (RIR 1.5)')