From 62b69ea88d9c6918f65e5e949046f3109a61ab35 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Tue, 25 Aug 2026 19:59:50 +0200 Subject: [PATCH] home + stats: stop asking for a workout that is done, plot bodyweight lifts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Home's week strip already knew today was finished — its dot goes 'done' from S.workouts — but the row underneath only ever asked `routine`, so a logged day kept showing the routine name behind a green Start tag and read as still outstanding (issue #4). It now reports the session instead. Tapping still starts another one; it just stops urging. Stats dropped every point whose value was 0, and a bodyweight pull-up has no weight, so "Exercise progress" read "No data yet" for exercises with a full history behind them (issue #5). When nothing in an exercise's history was ever loaded, its progress IS the rep count, so that is what gets plotted, labelled in reps. Add a weighted set later and it switches back to weight on its own — which is also the honest reading, because that is when load became the thing improving. Same fallback in currentOf, or the picker label went blank and the exercise sorted to the bottom as if it had no history at all. --- frontend/src/views/Home.jsx | 18 +++++++++++++++--- frontend/src/views/Stats.jsx | 24 +++++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsx index 1a751f8..a7abcc7 100644 --- a/frontend/src/views/Home.jsx +++ b/frontend/src/views/Home.jsx @@ -26,6 +26,9 @@ export default function Home() { const monday = new Date(today); monday.setDate(today.getDate() - ((today.getDay() + 6) % 7) + weekOffset * 7) const doneDays = new Set(S.workouts.map(w => w.d)) + // The last session logged for today, if any — what the row below reports instead of asking + // you to start the one you already did. Last wins, so a second session names itself. + const doneToday = S.workouts.filter(w => w.d === todayISO()).at(-1) || null const strip = [] for (let i = 0; i < 7; i++) { const d = new Date(monday); d.setDate(monday.getDate() + i) @@ -58,17 +61,26 @@ export default function Home() {
{strip}
+ {/* Once today's session is logged the row stops asking for it. The week strip already + knew (its dot goes 'done'); this row did not, so a finished day kept showing the + routine name behind a green Start tag and read as still outstanding (issue #4). + An in-progress session still wins — that one is happening right now. Tapping the + row keeps working, so a second session in one day is a tap away, just not urged. */}
- - + +
{t('Today')}
-
{S.active ? t('{0} — in progress', S.active.name) : routine ? routine.name : t('Rest day')}{todayOvr && routine ? ' · ' + t('rescheduled') : ''}
+
{S.active ? t('{0} — in progress', S.active.name) + : doneToday ? (doneToday.name ? t('{0} — done', doneToday.name) : t('Workout done')) + : routine ? routine.name : t('Rest day')}{todayOvr && routine && !doneToday ? ' · ' + t('rescheduled') : ''}
{S.active ? {t('Resume')} + : doneToday ? {t('Done')} : routine ? {t('Start')} : }
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx index 0140e72..9bd4621 100644 --- a/frontend/src/views/Stats.jsx +++ b/frontend/src/views/Stats.jsx @@ -300,6 +300,12 @@ export default function Stats() { const rows = metricRowsForEntry(en, mode) const mx = mode === 'reps' ? bestWeightForEntry(en) : Math.max(0, ...rows.map(s => mode === 'cardio' ? (s.speed || 0) : mode === 'time' ? (s.sec || 0) : (s.w || 0))) if (mx > 0) return { mx, unit: mode === 'cardio' ? 'km/h' : mode === 'time' ? 's' : S.unit } + // Unloaded reps work still has a current figure — its rep count. Without this the whole + // picker label went blank and the exercise sorted to the bottom as if it had no history. + if (mode === 'reps') { + const reps = Math.max(0, ...rows.map(s => Number(s.r) || 0)) + if (reps > 0) return { mx: reps, unit: t('reps') } + } } return { mx: 0, unit: S.unit } } @@ -321,8 +327,18 @@ export default function Stats() { })() : 'reps' const curCardio = curMode === 'cardio' const curTimed = curMode === 'time' + // A pull-up or a push-up carries no weight, so its "best weight" is 0 — and dropping every + // zero point left the card reading "No data yet" for exercises with a full history behind + // them (issue #5). When nothing in an exercise's history was ever loaded, the progress IS + // the rep count, so plot that. Add a weighted set later and it switches back to weight on + // its own, which is also the honest reading: that is when load became the thing improving. + const repsOnly = curEx && curMode === 'reps' && !workouts.some(w => { + const en = w.entries.find(e => e.id === curEx) + return en && bestWeightForEntry(en) > 0 + }) + const bestRepsOf = en => Math.max(0, ...metricRowsForEntry(en, 'reps').map(s => Number(s.r) || 0)) const metric = s => curCardio ? (s.speed || 0) : curTimed ? (s.sec || 0) : (s.w || 0) - const exUnit = curCardio ? 'km/h' : curTimed ? 's' : S.unit + const exUnit = curCardio ? 'km/h' : curTimed ? 's' : repsOnly ? t('reps') : S.unit let exPts = [], exList = [], exBest = 0 if (curEx) { workouts.forEach(w => { @@ -331,7 +347,9 @@ export default function Stats() { const loggedMode = metricModeForEntry(en) if (loggedMode !== curMode) return const doneSets = metricRowsForEntry(en, curMode) - const mx = curMode === 'reps' ? bestWeightForEntry(en) : Math.max(0, ...doneSets.map(metric)) + const mx = curMode === 'reps' + ? (repsOnly ? bestRepsOf(en) : bestWeightForEntry(en)) + : Math.max(0, ...doneSets.map(metric)) if (mx > 0) { exPts.push({ t: w.start, y: mx, d: w.d, sets: doneSets, target: en.target }) if (mx > exBest) exBest = mx @@ -413,7 +431,7 @@ export default function Stats() {
{exList.map((p, i) =>
{fmtDate(p.d, true)}{p.sets.map(s => setLabel(curEx, s, p.target)).join(' ')}
)}
- {onEff ? t('Average effort per workout') : onE1 ? t('Estimated 1RM per workout') : curCardio ? t('Top speed per workout') : curTimed ? t('Longest hold per workout') : t('Best set weight per workout')} + {onEff ? t('Average effort per workout') : onE1 ? t('Estimated 1RM per workout') : curCardio ? t('Top speed per workout') : curTimed ? t('Longest hold per workout') : repsOnly ? t('Most reps in a set per workout') : t('Best set weight per workout')} {onEff ? '' : <> · {t('Best:')}{' '}{fmtNum(onE1 ? e1Best.est : exBest)} {onE1 ? S.unit : exUnit}}
{onE1 &&