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: Pagy::OverflowError #3528

Merged
merged 3 commits into from
Dec 16, 2024
Merged

fix: Pagy::OverflowError #3528

merged 3 commits into from
Dec 16, 2024

Conversation

Paul-Bob
Copy link
Contributor

@Paul-Bob Paul-Bob commented Dec 13, 2024

Description

Fixes #2468

Fixes a pagination overflow error that might occur in cases where the default query has fewer pages than the query with certain filters applied.

Let's take a simple example. Suppose that there are only 1000 employees in the system, and Johan Wang supervises 20 people, and he is viewing 10 per page, so he has 2 pages of results. If he sets the filters to show everyone (which is not the default, but is available to him) then suddenly there are 100 pages. He can advance all the way to page 100 and everything works until he resets the filters back to his default. That's when there's an error.

Originally posted by @brandondrew in #2468


Fixes #3522


Since we had fixed many Pagy::OverflowError and they still appear made me realise that we should implement a pagination fallback and reset page to 1 when overflow error is raised othwerise we can keep the current page

Related issues:

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@github-actions github-actions bot added the Fix label Dec 13, 2024
Copy link

codeclimate bot commented Dec 13, 2024

Code Climate has analyzed commit c3bf76d and detected 0 issues on this pull request.

View more on Code Climate.

@Paul-Bob Paul-Bob self-assigned this Dec 13, 2024
@Paul-Bob Paul-Bob changed the title fix: pagy overflow when reset filters fix: Pagy::OverflowError Dec 13, 2024
@Paul-Bob Paul-Bob merged commit 2585b4f into main Dec 16, 2024
20 checks passed
@Paul-Bob Paul-Bob deleted the fix/pagy_overflow_on_filters_reset branch December 16, 2024 01:31
Copy link
Contributor

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

@mtomov
Copy link

mtomov commented Dec 18, 2024

This is amazing, thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants