home + stats: stop asking for a workout that is done, plot bodyweight lifts
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.
This commit is contained in:
1 parent
46eaefd2c7
commit
62b69ea88d
2 files changed
+36
-6
No files matched your search
@@ -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() {
|
||||
<button className="iconbtn" style={{ width: 30, height: 30, fontSize: 15 }} onClick={() => setWeekOffset(w => w + 1)} aria-label="Next week"><Icon name="chevronRight" /></button>
|
||||
</div>
|
||||
<div className="week">{strip}</div>
|
||||
{/* 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. */}
|
||||
<div className="today-row" onClick={onToday}>
|
||||
<div className="row" style={{ gap: 9, minWidth: 0 }}>
|
||||
<span className="lrow-i" style={{ background: S.active ? 'var(--orange)' : routine ? 'var(--acc)' : 'var(--surface-3)' }}>
|
||||
<Icon name={S.active ? 'timer' : routine ? glyphOf(routine.emoji) : 'moon'} />
|
||||
<span className="lrow-i" style={{ background: S.active ? 'var(--orange)' : doneToday ? 'var(--surface-3)' : routine ? 'var(--acc)' : 'var(--surface-3)' }}>
|
||||
<Icon name={S.active ? 'timer' : doneToday ? 'checkCircle' : routine ? glyphOf(routine.emoji) : 'moon'}
|
||||
style={doneToday && !S.active ? { color: 'var(--green)' } : undefined} />
|
||||
</span>
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<div className="lbl2">{t('Today')}</div>
|
||||
<div className="ttl">{S.active ? t('{0} — in progress', S.active.name) : routine ? routine.name : t('Rest day')}{todayOvr && routine ? ' · ' + t('rescheduled') : ''}</div>
|
||||
<div className="ttl">{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') : ''}</div>
|
||||
</div>
|
||||
</div>
|
||||
{S.active ? <span className="tag" style={{ color: 'var(--orange)', background: 'color-mix(in srgb,var(--orange) 16%,transparent)' }}>{t('Resume')}</span>
|
||||
: doneToday ? <span className="tag" style={{ color: 'var(--green)', background: 'color-mix(in srgb,var(--green) 16%,transparent)' }}>{t('Done')}</span>
|
||||
: routine ? <span className="tag acc">{t('Start')}</span>
|
||||
: <Icon name="plus" className="chev" />}
|
||||
</div>
|
||||
|
||||
@@ -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() {
|
||||
<div style={{ marginTop: 8 }}>{exList.map((p, i) => <div key={i} className="row between small" style={{ padding: '6px 0', borderBottom: 'var(--hair) solid var(--sep)' }}>
|
||||
<span className="muted">{fmtDate(p.d, true)}</span><span>{p.sets.map(s => setLabel(curEx, s, p.target)).join(' ')}</span></div>)}</div>
|
||||
<div className="small dim" style={{ marginTop: 8 }}>
|
||||
{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:')}{' '}<b className="accent">{fmtNum(onE1 ? e1Best.est : exBest)} {onE1 ? S.unit : exUnit}</b></>}
|
||||
</div>
|
||||
{onE1 && <div className="small dim" style={{ marginTop: 4 }}>
|
||||
|
||||
Reference in new issue
Block a user