Skip to content

Order preset workouts deliberately instead of randomly (#78) - #81

Merged
NeoLorenzo merged 2 commits into
mainfrom
claude/fix-78-preset-ordering-dd147d
Oct 17, 2026
Merged

NeoLorenzo merged 2 commits into
mainfrom
claude/fix-78-preset-ordering-dd147d

Conversation

@NeoLorenzo

Copy link
Copy Markdown
Owner

Closes #78.

What changes

  • No more random shuffle. Preset-started workouts default to balanced rotation: the order is based on the order actually performed in previous sessions from the same preset, so each exercise takes a turn going first.
  • Optional settings: muscle-group priority (put chosen muscle groups early) and alternating exercises between main muscle groups. Muscle groups come from the current exercise → muscle relevance version.
  • Explainable. The order is computed by the pure, tested preset-ordering.js. The order and its basis are stored on the session in workout_sessions.exercise_order_basis. Product rationale: docs/PRESET_EXERCISE_ORDER.md, linked from Literature.
  • Equipment defaults follow Normalize canonical equipment identity across gyms and separate equipment from exercise identity #22. Each preset exercise defaults to the canonical equipment last used at that gym.

Migration

supabase/migrations/20261018120000_order_preset_workouts.sql. It sorts after #22's migrations and stops with an error if #22 isn't applied.

Validation

npm run agent:check passes locally against the disposable DB: syntax, 228 node tests, and all pgTAP files. Not yet clicked through in a browser.

Follow-up (not in this PR)

Production still has two old August overloads: start_or_resume_workout_session() and (p_preset_id bigint). They don't clash with this change and could be dropped in a separate cleanup.

Deploying

Merging deploys the frontend through GitHub Pages straight away, so apply the migration to production at the same time.

Preset-started workouts use balanced rotation by default (based on the
order actually performed in previous sessions from the same preset), with
optional muscle-group priority and muscle-group alternation. The order and
its basis are stored on the session so it is explainable. Preset exercises
default to the canonical equipment last used at the gym, as in #22.

Closes #78.
# Conflicts:
#	package.json
#	service-worker.js
@NeoLorenzo
NeoLorenzo merged commit 3626bb3 into main Oct 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Order preset workouts by balanced rotation or muscle-group priority, with optional exercise alternation

1 participant