Progression reads the sets the plan asked for, not the extra ones logged on top (#233)
An extra set — the one you add because you felt strong, or to chase a heavy single — was read as part of the prescription. A heavier bonus set pulled the weight for the next session up with it, and a bonus set taken short of the target reps reported the whole session as missed and started counting stalls toward a deload. `readSession` now stops at the planned number of work sets. A set past that is still logged, still counts in the volume, the PRs and the history; it just has no say in what the plan does next. A session with fewer sets than planned is short exactly as before.
This commit is contained in:
1 parent
a7d710902c
commit
b5d55467d0
2 files changed
+63
-3
No files matched your search
@@ -0,0 +1,53 @@
|
||||
// Issue #233: a set logged on top of the plan is extra work, not part of the prescription.
|
||||
// Before this, one heavier bonus set pulled the next session's weight up with it, and a bonus
|
||||
// set taken short of the target reps reported the whole session as missed.
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { readSession } from './progression.js'
|
||||
|
||||
const set = (w, r, done = true) => ({ w, r, done })
|
||||
const entry = (target, sets) => ({ id: '0025', target, sets })
|
||||
const plan = { mode: 'reps', sets: 3, reps: 8, weight: 60 }
|
||||
|
||||
describe('extra sets stay out of the progression read', () => {
|
||||
it('ignores a heavier bonus set when reading the weight', () => {
|
||||
const done = readSession(entry(plan, [set(60, 8), set(60, 8), set(60, 8), set(80, 8)]))
|
||||
expect(done.weight).toBe(60)
|
||||
expect(done.ok).toBe(true)
|
||||
})
|
||||
|
||||
it('does not call the session missed because a bonus set fell short', () => {
|
||||
const done = readSession(entry(plan, [set(60, 8), set(60, 8), set(60, 8), set(80, 3)]))
|
||||
expect(done.ok).toBe(true)
|
||||
expect(done.low).toBe(8)
|
||||
expect(done.count).toBe(3)
|
||||
// Greyskull reads the last set of the plan, not whatever was tacked on after it
|
||||
expect(done.amrap).toBe(8)
|
||||
})
|
||||
|
||||
it('still reports a short session as short, and still reads every planned set', () => {
|
||||
const short = readSession(entry(plan, [set(60, 8), set(60, 5), set(60, 8)]))
|
||||
expect(short.ok).toBe(false)
|
||||
expect(short.low).toBe(5)
|
||||
const missing = readSession(entry(plan, [set(60, 8), set(60, 8)]))
|
||||
expect(missing.ok).toBe(false)
|
||||
})
|
||||
|
||||
it('reads everything when the plan names no set count (freestyle)', () => {
|
||||
const free = readSession(entry({ mode: 'reps', reps: 8 }, [set(60, 8), set(80, 8)]))
|
||||
expect(free.weight).toBe(80)
|
||||
expect(free.count).toBe(2)
|
||||
})
|
||||
|
||||
it('leaves warm-ups out before counting, so a warm-up does not eat a planned slot', () => {
|
||||
const warm = readSession(entry(plan, [{ w: 20, r: 10, done: true, phase: 'warmup' }, set(60, 8), set(60, 8), set(60, 8), set(90, 8)]))
|
||||
expect(warm.weight).toBe(60)
|
||||
expect(warm.ok).toBe(true)
|
||||
})
|
||||
|
||||
it('applies the same rule to a timed hold', () => {
|
||||
const timed = { mode: 'time', sets: 2, sec: 30, weight: 0 }
|
||||
const held = readSession(entry(timed, [{ sec: 30, done: true }, { sec: 30, done: true }, { sec: 12, done: true }]))
|
||||
expect(held.ok).toBe(true)
|
||||
expect(held.best).toBe(30)
|
||||
})
|
||||
})
|
||||
@@ -219,9 +219,16 @@ export function readSession(entry, fallback) {
|
||||
const mode = modeOf({ ...target, id: entry && entry.id })
|
||||
// Warm-up rows are prep, not the session: one filtered read beats guarding every consumer
|
||||
// below (an undone warm-up otherwise poisons `ok` forever and its reps drag `low`/`count`).
|
||||
const sets = ((entry && entry.sets) || []).filter(s => !isWarmupRow(s))
|
||||
const planned = target.sets || sets.length
|
||||
const enough = sets.length >= planned
|
||||
const logged = ((entry && entry.sets) || []).filter(s => !isWarmupRow(s))
|
||||
const planned = target.sets || logged.length
|
||||
const enough = logged.length >= planned
|
||||
// Only the sets the plan asked for decide what happens next (issue #233). A set added on top
|
||||
// is extra work, and it used to be read as part of the prescription: one heavier bonus set
|
||||
// raised the weight for next time, and a hard one taken short of the target reps reported the
|
||||
// whole session as missed. Extra sets still count everywhere else — volume, PRs, history —
|
||||
// they just do not move the plan. The plan's own sets are the ones it laid out first, so the
|
||||
// read stops at that many; a session with fewer than planned is short either way (`enough`).
|
||||
const sets = logged.slice(0, Math.max(1, planned))
|
||||
|
||||
if (mode === 'time') {
|
||||
const goal = target.sec || 0
|
||||
|
||||
Reference in new issue
Block a user