Skip to content

feat: gym-wide shared templates and exercise library#170

Merged
ChristopherRotnes merged 3 commits into
masterfrom
claude/suggest-trainer-features-LXbc2
May 14, 2026
Merged

feat: gym-wide shared templates and exercise library#170
ChristopherRotnes merged 3 commits into
masterfrom
claude/suggest-trainer-features-LXbc2

Conversation

@ChristopherRotnes
Copy link
Copy Markdown
Owner

@ChristopherRotnes ChristopherRotnes commented May 14, 2026

Summary

  • session_templates and exercise_library are now fully shared across all co-instructors at the same gym — any instructor can create, edit, rename, and delete any template or exercise
  • RLS on all three tables (session_templates, session_template_exercises, exercise_library) replaced with gym-aware policies using the user_gyms EXISTS subquery pattern already in place for sessions
  • user_id retained on both tables as "created by" for display attribution only
  • Creator name shown ("Av [name]") on template cards and exercise rows in Bibliotek when item was created by a colleague
  • "Mine maler" tab label renamed to "Maler" across all three locales (nb/en/fa)
  • Removed defensive .eq("user_id", user.id) filters from updateTemplateName, deleteTemplate, touchTemplate, updateLibraryExercise, deleteLibraryExercise in db.js
  • Added profiles!user_id(display_name) join to fetchTemplates and fetchLibraryExercises

Note on history

Editing an exercise's muscle mapping does not retroactively update historical sessions. muscle_activations rows are permanent snapshots written at log time with no FK to exercise_library. A separate issue (#172) tracks retroactive remapping as a future feature.

Test plan

  • Log in as instructor A — create a template and an exercise
  • Log in as instructor B (same gym) — confirm template and exercise appear in Bibliotek with "Av [A's display name]"
  • Instructor B edits template name and exercises — confirm save succeeds
  • Instructor B deletes an exercise — confirm gone for instructor A too
  • Planlegger: assign instructor A's template as instructor B — confirm touchTemplate succeeds (no silent failure)
  • Confirm History, week plans, and Report are unaffected
  • Run npm test — all 82 tests pass

https://claude.ai/code/session_01BX3VsjZbhAR5n85NbUmZRJ

Templates and exercises are now visible and editable by all co-instructors
at the same gym. Replaces user-private RLS (auth.uid() = user_id) with
gym-aware policies using the same user_gyms EXISTS subquery pattern already
in place for sessions. Creator attribution shown in Bibliotek. Tab label
"Mine maler" → "Maler".

https://claude.ai/code/session_01BX3VsjZbhAR5n85NbUmZRJ
@ChristopherRotnes ChristopherRotnes marked this pull request as ready for review May 14, 2026 00:12
Resolved CHANGELOG conflict — master had added 1.2.5/1.2.6/1.2.7;
our gym-wide templates entry renumbered to 1.2.8.

https://claude.ai/code/session_01BX3VsjZbhAR5n85NbUmZRJ
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-170.westeurope.7.azurestaticapps.net

…iles

Both user_id columns previously referenced auth.users(id). PostgREST
cannot traverse auth.users → profiles so the profiles!user_id join in
fetchTemplates and fetchLibraryExercises failed with "could not find
a relationship" at runtime. Rewired both FKs to profiles(id) to match
the sessions.trainer_id pattern.

https://claude.ai/code/session_01BX3VsjZbhAR5n85NbUmZRJ
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-170.westeurope.7.azurestaticapps.net

@ChristopherRotnes ChristopherRotnes merged commit 89c304d into master May 14, 2026
1 check passed
@ChristopherRotnes ChristopherRotnes deleted the claude/suggest-trainer-features-LXbc2 branch May 14, 2026 00:22
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.

2 participants