feat: gym-wide shared templates and exercise library#170
Merged
Conversation
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
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
|
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
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-170.westeurope.7.azurestaticapps.net |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
session_templatesandexercise_libraryare now fully shared across all co-instructors at the same gym — any instructor can create, edit, rename, and delete any template or exercisesession_templates,session_template_exercises,exercise_library) replaced with gym-aware policies using theuser_gymsEXISTS subquery pattern already in place for sessionsuser_idretained on both tables as "created by" for display attribution only.eq("user_id", user.id)filters fromupdateTemplateName,deleteTemplate,touchTemplate,updateLibraryExercise,deleteLibraryExerciseindb.jsprofiles!user_id(display_name)join tofetchTemplatesandfetchLibraryExercisesNote on history
Editing an exercise's muscle mapping does not retroactively update historical sessions.
muscle_activationsrows are permanent snapshots written at log time with no FK toexercise_library. A separate issue (#172) tracks retroactive remapping as a future feature.Test plan
touchTemplatesucceeds (no silent failure)npm test— all 82 tests passhttps://claude.ai/code/session_01BX3VsjZbhAR5n85NbUmZRJ