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
Follow-up to #263: moving a workout judges an assistance machine's record the way the finish sheet does, less help first
Duarte Santosd1907baa32f0
diff --git a/frontend/src/lib/workout-date.js b/frontend/src/lib/workout-date.jsindex 41b91a25a..5db110c1d 100644--- a/frontend/src/lib/workout-date.js+++ b/frontend/src/lib/workout-date.js@@ -9,6 +9,7 @@// existed) so the date arithmetic and the badge surgery are testable without the UI.import { insertChronological, backfillStart } from './backfill.js'import { bestWeightForEntry } from './history.js'+import { beatsWeight } from './exercises.js'// Before ids existed a workout was keyed for sync by its day and start time// (`workoutKey` in sync-merge.js). That is exactly what this edit changes, so moving such a@@ -65,8 +66,10 @@ export function rebuildPrHistory(workouts, exerciseIds, moved = null) {trains = trueconst top = bestWeightForEntry(e)// Leads everything dated before it. The running best grows whether or not a badge is- // written, so a session that cannot gain one still raises the bar for the next.- const leads = top > 0 && top > (best.get(e.id) || 0)+ // written, so a session that cannot gain one still raises the bar for the next. "Leads"+ // is the finish sheet's own test (beatsWeight): on an assistance machine the record is the+ // least help, so there a lighter load leads (issue #232).+ const leads = beatsWeight(e.id, top, best.get(e.id) || 0)if (leads) best.set(e.id, top)if (leads && (w === moved || had.includes(e.id))) kept.push(e.id)}diff --git a/frontend/src/lib/workout-date.test.js b/frontend/src/lib/workout-date.test.jsindex 8514dcee4..978b44a5e 100644--- a/frontend/src/lib/workout-date.test.js+++ b/frontend/src/lib/workout-date.test.js@@ -158,6 +158,17 @@ describe('rebuildPrHistory', () => {], ['bench'], moved)expect(out.map(x => x.prs)).toEqual([[], []])})+ // Less help is the record on an assistance machine (issue #232): the finish sheet awards the+ // badge that way, and a move must judge it the same way round.+ it('on an assistance machine the session with less help leads', () => {+ const assisted = '0017'+ const moved = w('moved', '2026-01-01', '18:00', 60, [entry(assisted, 20)], [])+ const out = rebuildPrHistory([+ moved,+ w('later', '2026-01-08', '18:00', 60, [entry(assisted, 30)], [assisted]),+ ], [assisted], moved)+ expect(out.map(x => x.prs)).toEqual([[assisted], []])+ })it('does nothing without exercises and never mutates the input', () => {const list = [w('a', '2026-01-01', '18:00', 60, [entry('bench', 100)], ['bench'])]expect(rebuildPrHistory(list, [])).toBe(list)