Skip to content

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.

Merge !103: feat: use Epley-based targets for automatic deloads

Duarte Santos6d2b22da635c
diff --cc frontend/src/lib/progression.test.js
index 25798139f,fbee03b67..35ef1d296
--- a/frontend/src/lib/progression.test.js
+++ b/frontend/src/lib/progression.test.js
@@@ -364,39 -396,38 +414,68 @@@ describe('double progression', () =>
const p = nextPrescription(hist(LIFT, rows, { sets: 3, reps: 12 }), cfg)
expect(p.kind).toBe('deload')
expect(p.reps).toBe(8)
- expect(p.weight).toBe(35) // 40 × 0.9 = 36 → nearest loadable 2.5 step
+ expect(p.weight).toBe(40) // 40 × 8 is the closest valid Epley candidate
})
+ it('climbs a range wider than the deload budget instead of cutting on the way up', () => {
+ // We consider a 8-12 rep range, so 4 rep steps one per session.
+ // This is graded against DELOAD_AFTER.double which allows for 2 stalls towards progress.
+ // And only a hit at the top clears a stall.
+ // With our rep range reaching the top thus cannot be achieved within the current budget of 3.
+ // Therefore we wish to count the climb as progress as well.
+ expect(cfg.reps - cfg.repsMin).toBeGreaterThan(DELOAD_AFTER.double - 1)
+
+ const target = { sets: 3, reps: cfg.reps }
+ const rows = []
+ let p = { weight: cfg.weight, reps: cfg.repsMin }
+ for (let session = 1; session <= 5; session++) {
+ // Train exactly what was prescribed, every set, every session.
+ rows.push([p.weight, ...Array(target.sets).fill(p.reps)])
+ p = nextPrescription(hist(LIFT, rows, target), cfg)
+ expect(p.kind).not.toBe('deload')
+ }
+
+ // Five compliant sessions later the top of the range is reached and the weight goes up.
+ expect(p.kind).toBe('up')
+ expect(p.weight).toBeGreaterThan(cfg.weight)
+ expect(p.reps).toBe(cfg.repsMin)
+ })
+
+ it('normalizes persisted per-side bounds before prescribing', () => {
+ const perSide = { ...cfg, reps: 13, repsMin: 7, side: true }
+ const p = nextPrescription(hist(LIFT, [[40, 12, 12, 12]], { sets: 3, reps: 13 }), perSide)
+ expect(p.kind).toBe('hold')
+ expect(p.reps).toBe(14)
++
+ it('selects a lower in-range rep target and never increases the attempted load', () => {
+ const target = { sets: 3, reps: 12, weight: 40 }
+ const p = nextPrescription(hist(LIFT, [[40, 9, 9, 9], [40, 9, 9, 9], [40, 9, 9, 9]], target), cfg)
+ expect(p.kind).toBe('deload')
+ expect(p.reps).toBeGreaterThanOrEqual(8)
+ expect(p.reps).toBeLessThanOrEqual(12)
+ expect(p.weight).toBeLessThanOrEqual(40)
+ expect(p.target1RM).toBe(deloadTarget1RM(40, 12))
+ })
+
+ it('keeps a 5 kg load and lowers reps when that is closer than a 50% weight cut', () => {
+ const small = { id: LIFT, sets: 3, reps: 8, repsMin: 4, weight: 5, inc: 2.5, prog: 'double' }
+ const target = { sets: 3, reps: 8, weight: 5 }
+ const p = nextPrescription(hist(LIFT, [[5, 6, 6, 6], [5, 6, 6, 6], [5, 6, 6, 6]], target), small)
+ expect(p.kind).toBe('deload')
+ expect(p.weight).toBe(5)
+ expect(p.reps).toBe(4)
+ expect(p.target1RM).toBe(deloadTarget1RM(5, 8))
+ })
+
+ it('uses half the reps for per-side Epley and returns an even total', () => {
+ const perSide = { ...cfg, reps: 8, side: true }
+ const target = { sets: 3, reps: 8, weight: 60, side: true }
+ const p = nextPrescription(hist(LIFT, [[60, 6, 6, 6], [60, 6, 6, 6], [60, 6, 6, 6]], target), perSide)
+ expect(p.kind).toBe('deload')
+ expect(p.reps % 2).toBe(0)
+ expect(p.target1RM).toBe(deloadTarget1RM(60, 8, 0.9, true))
})
+
})
describe('timed progression', () => {