Effort stats: the other ten languages, and drop what nothing calls

The card shipped translated into German only, so every other UI language fell
back to the English source strings mid-sentence — the locale files have been
key-for-key identical until now, and they are again (607 each).

exerciseEffort() had no caller: Stats builds its per-exercise curve from the
points it already has, which are filtered by training mode, so the library
version would have drawn a different set of sessions. Removed with its tests
rather than left as a second answer to the same question.
This commit is contained in:
Duarte Santos committed 2026-07-31 16:55:21 +02:00
1 parent caaf61d91e
commit f232b5ba7e
12 files changed
+183 -34

No files matched your search

-15
View File
@@ -135,20 +135,5 @@ export function effortHistogram(S, days) {
return bins.map((n, i) => ({ rir: i, tail: i === BUCKETS, n, pct: rated ? n / rated : 0 }))
}
/**
* Average effort per session for one exercise, oldest first. Sessions where the exercise was
* logged but never rated are absent, not zero — an unrated set must never read as failure.
*/
export function exerciseEffort(S, exId) {
const pts = []
;(S.workouts || []).forEach(w => {
const en = (w.entries || []).find(e => e.id === exId)
if (!en) return
const r = avgRir((en.sets || []).filter(s => s.done))
if (r != null) pts.push({ t: w.start || new Date(w.d).getTime(), d: w.d, rir: r })
})
return pts
}
/** A set that counts as hard — the filter behind the muscle map's "hard sets" mode. */
export const isHardSet = s => { const r = rirOf(s); return r != null && r <= HARD_RIR }
+3 -19
View File
@@ -1,16 +1,16 @@
import { describe, it, expect } from 'vitest'
import {
rirOf, toScale, displayScale, avgRir, effortSummary, hasEffort, effortWeeks,
effortHistogram, exerciseEffort, isHardSet, HARD_RIR, MIN_RATED
effortHistogram, isHardSet, HARD_RIR, MIN_RATED
} from './effort.js'
import { isoOf } from './format.js'
const daysAgo = n => { const d = new Date(); d.setDate(d.getDate() - n); return d }
// One workout on a day, with the sets given. Everything here is a finished set unless a set
// says otherwise, because that is what the stats read.
const W = (n, sets, id = '0025') => {
const W = (n, sets) => {
const d = daysAgo(n)
return { id: 'w' + n, d: isoOf(d), start: +d, entries: [{ id, sets: sets.map(s => ({ w: 60, r: 8, done: true, ...s })) }] }
return { id: 'w' + n, d: isoOf(d), start: +d, entries: [{ id: '0025', sets: sets.map(s => ({ w: 60, r: 8, done: true, ...s })) }] }
}
const S = (...workouts) => ({ workouts })
@@ -165,22 +165,6 @@ describe('effortHistogram', () => {
})
})
describe('exerciseEffort', () => {
it('gives one point per session, in order', () => {
const st = S(W(20, [{ rir: 4 }, { rir: 2 }]), W(2, [{ rir: 1 }]))
expect(exerciseEffort(st, '0025').map(p => p.rir)).toEqual([3, 1])
})
it('skips a session where the exercise was logged but never rated', () => {
const st = S(W(20, [{}]), W(2, [{ rir: 1 }]))
expect(exerciseEffort(st, '0025')).toHaveLength(1)
})
it('does not pick up another exercise', () => {
expect(exerciseEffort(S(W(2, [{ rir: 1 }], '0047')), '0025')).toEqual([])
})
})
describe('isHardSet', () => {
it('draws the line at the effort that actually drives adaptation', () => {
expect(isHardSet({ rir: HARD_RIR })).toBe(true)