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: a planned rest-pause set whose total was raised by hand reads as its total, not as a made-up first burst in front of the planned ones
Duarte Santos4bf4403164b4
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 697533555..97a16fa51 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -123,11 +123,17 @@ export function setLabel(id, s, cfg, speedUnit) {// down. The row's own `r` is the total either way; a planned set's bursts already add up to it// (applyIntensifierPlan), while bursts added live sit on top of the activation set, which is// then whatever the total leaves over. Bursts that do not fit the total are not shown.+ // A planned set has no activation set in front of its bursts, so when its total was raised by+ // hand the leftover is not one: "60×2+6+3+2+1" read as a two-rep set nobody did. Which burst+ // the extra reps belong to is not known, so such a set reads as its plain total. The target+ // says whether the exercise plans rest-pause; a row added to it and given bursts live can only+ // be told apart by that, and reads as its plain total too, which is still what was lifted.+ const planned = c.intensifier?.type === 'restpause'const repsOf = side => {const reps = side.r || 0const bursts = clustersOf(side).map(b => Number(b?.r) || 0).filter(r => r > 0)const sum = bursts.reduce((a, b) => a + b, 0)- if (!bursts.length || sum > reps) return reps+ if (!bursts.length || sum > reps || (planned && sum !== reps)) return repsreturn (reps > sum ? [reps - sum, ...bursts] : bursts).join('+')}// One side's "weight×reps" (or bodyweight "reps" / "+belt × reps"), the same shape a wholediff --git a/frontend/src/lib/history.test.js b/frontend/src/lib/history.test.jsindex b03bf3f27..5a91e9a65 100644--- a/frontend/src/lib/history.test.js+++ b/frontend/src/lib/history.test.js@@ -121,6 +121,24 @@ describe('setLabel', () => {expect(setLabel(LIFT, { w: 60, r: 5, type: 'restpause', clusters: [{ r: 4 }, { r: 3 }] })).toBe('60×5')})+ // A planned rest-pause set has no activation set: its bursts are the whole total. Raising the+ // total by hand put the difference in front, "60×2+6+3+2+1", a two-rep set nobody did.+ it('reads a planned rest-pause set whose total was raised by hand as its plain total', () => {+ const cfg = { id: LIFT, reps: 8, intensifier: { type: 'restpause', totalReps: 12, restSec: 15 } }+ const [, work] = applyIntensifierPlan([{ w: 60, r: 8, done: false }], cfg)+ expect(setLabel(LIFT, work, cfg)).toBe('60×6+3+2+1')+ expect(setLabel(LIFT, { ...work, r: 14 }, cfg)).toBe('60×14')+ // a burst added live on top keeps the breakdown, since the total follows it+ const added = { ...work, r: 13, clusters: [...work.clusters, { r: 1, restSec: 15 }] }+ expect(setLabel(LIFT, added, cfg)).toBe('60×6+3+2+1+1')+ // per side, each side is read the same way+ const sided = applyIntensifierPlan([makeSideSet({ w: 20, r: 8, done: false })], { ...cfg, side: true })[1]+ sided.sides.L = { ...sided.sides.L, r: sided.sides.L.r + 2 }+ expect(setLabel(LIFT, sided, { ...cfg, side: true })).toBe('L 20×8 · R 20×3+2+1')+ // an unplanned set with live bursts still shows its activation set first+ expect(setLabel(LIFT, { w: 60, r: 16, type: 'restpause', clusters: [{ r: 4 }, { r: 2 }] }, { id: LIFT, reps: 10 })).toBe('60×10+4+2')+ })+it('reads drops and bursts of a bodyweight exercise as reps and added weight', () => {const cfg = { id: BW, bodyweight: true }expect(setLabel(BW, { w: 10, r: 8, type: 'dropset', drops: [{ w: 0, r: 5 }] }, cfg)).toBe('+10 × 8 ↘ 5')