Skip to content

Load all muscles instead of only the first page - #1327

Open
whoalin1 wants to merge 1 commit into
wger-project:masterfrom
whoalin1:fix/load-all-muscles
Open

whoalin1 wants to merge 1 commit into
wger-project:masterfrom
whoalin1:fix/load-all-muscles

Conversation

@whoalin1

Copy link
Copy Markdown
Contributor

Proposed Changes

  • getMuscles() read only results of the first response from /api/v2/muscle/. With the server's default page size, once an instance has more than 20 muscles (e.g. after an admin adds custom ones), the rest never reach the muscle selectors in exercise creation and the other places that use useMusclesQuery. This is what's described in the issue: some muscles disappear, and they come back once the total is down to 20.
  • It now requests limit=API_MAX_PAGE_SIZE and follows next through the existing fetchPaginated() helper, the same way getExercises() and the session/measurement APIs already do.

getEquipment() (and possibly categories) use the same single-page pattern. I left them out to keep this PR to the reported bug, but can do the same change in a follow-up if you want.

Related Issue(s)

Closes wger-project/wger#1737

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)

New test in muscles.test.ts: with a two-page response, getMuscles() returns muscles from both pages, the first request carries the max page size, and the second request uses the next URL. It fails without the change.

What I ran locally (Node 24): LANG=de_de npx vitest run (180 files / 1175 tests pass), npx eslint src/components/Exercises/api, and npx tsc --noEmit. I didn't check this against a running server with more than 20 muscles.

AI assistance was used to write this change. I reviewed the diff and ran the checks above.

@rolandgeider

Copy link
Copy Markdown
Member

Thanks for the PR. Feel free to also check (and fix) the equipment and categories ones (but those will rarely go over the default page limit)

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 83.833% (+0.003%) from 83.83% — whoalin1:fix/load-all-muscles into wger-project:master

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.

Exercise creation: Newly added muscles are not available in the dropdown

3 participants