Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workers pagination issue where the whole relation was being loaded #94

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

rosa
Copy link
Member

@rosa rosa commented Mar 20, 2024

This is a follow-up on #28.

Due to the delegation of all count-related methods to to_a, we were loading the whole set of workers when calculating the number of pages and page size, which happens before we've set any limits or offsets in the relation. Moreover, once the limits and offsets were set, we weren't resetting the loaded workers, which means we were still returning all of them even with offset and limit.

I'd like to DRY a bit the two JobsRelation and WorkersRelation classes, which have a lot in common now, but this will do for now.

Due to the delegation of all count-related methods to `to_a`, we were loading
the whole set of workers when calculating the number of pages and page size,
which happens before we've set any limits or offsets in the relation. Moreover,
once the limits and offsets are set, we weren't resetting the loaded workers, which
means we were still returning all of them even with offset and limit.

This adds also a test for this and includes some minor cosmetic fixes.
@rosa rosa merged commit cfcaa59 into main Mar 20, 2024
10 checks passed
@rosa rosa deleted the fix-workers-pagination branch March 20, 2024 19:33
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.

1 participant