Combine routines (ENG-9) phase 1: data model + pure helpers
Model A, no new entity. Per-entry noProg replaces the whole-workout
excludeFromProgression flag; the planner day slot and the active/saved
session widen to routine-id lists. No migration — every reader tolerates
the old scalar shape.
- session-start.js: buildSessionEntries returns a bare array, stamps
entry.noProg (only when true) instead of an { entries, excluded } wrapper.
- session-merge.js (new): buildCombinedEntries(st, routineIds) concatenates
N routines' entries in order and stamps entry.rid; deriveSessionName.
- history.js: entryExcluded(w, entry) predicate; effectiveRoutineIds /
effectiveRoutines plural primaries with thin singular wrappers;
lastEntryFor skips excluded entries (retires the buildWorkSets `regular`
wrapper); nextTrainingDay iterates the day's routines.
- progression.js: sessionsFor drops the whole-workout return for a
per-entry entryExcluded check — the file's only exclusion path.
- finish-workout.js: carries rid/noProg onto saved entries; writes
routineIds + routineId mirror; excludeFromProgression mirror iff every
completed entry is noProg.
- plan-share.js: week schedule is a routine-id list through build / parse /
merge / print; [].concat tolerates a legacy scalar bundle value.
- mcp/tools.js, sheets.jsx loadStarterPlan: adjust to the new shapes.
Unit tests for every changed helper (session-merge new; progression cases
1-7; history 8-16; finish-workout 17-19; plan-share 20-22). Fixtures in
sheets.starter / coach migrated to the list shape.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JVbWJtoyQU4WgwFR4eAKgy
This commit is contained in:
1 parent
f97fcbccd7
commit
1c877173f4
16 files changed
+504
-65
No files matched your search
@@ -103,7 +103,7 @@ export function loadStarterPlan(planId) {
|
||||
if (!plan) return false
|
||||
update(st => {
|
||||
st.routines.push(...plan.routines)
|
||||
plan.schedule.forEach(({ day, routineId }) => { st.week[day] = routineId })
|
||||
plan.schedule.forEach(({ day, routineId }) => { st.week[day] = [routineId] })
|
||||
})
|
||||
toast(t('{0} loaded', PLAN_COPY[planId]().name))
|
||||
return true
|
||||
@@ -120,7 +120,7 @@ function StarterPlanChooser({ close }) {
|
||||
close()
|
||||
// A confirmation is only worth showing when one of those days is actually occupied — by a
|
||||
// routine that still exists, not by a stale id the Plan already shows as "Rest".
|
||||
const taken = day => week[day] && routines.some(r => r.id === week[day])
|
||||
const taken = day => [].concat(week[day] || []).some(id => routines.some(r => r.id === id))
|
||||
if (!days.some(taken)) { loadStarterPlan(id); return }
|
||||
confirmSheet({
|
||||
title: t('Load {0}?', name),
|
||||
|
||||
Reference in new issue
Block a user