-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
lowered pagination threshold in dev and staging using kaminari #4865
lowered pagination threshold in dev and staging using kaminari #4865
Conversation
Thanks for the call out on BaseItem! It turns out that we aren't too worried about that because we've only had to add a new BaseItem twice in the last 3 years -- It's super super stable -- and only seen by the superusers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@k8port linting is failing now - you can run it locally with bin/lint
.
@dorner
After there are no changes to commit. The workflow is giving a 502 error - could it be an issue with github server? I do not see an option to rerun job… |
@k8port I reran the failing lint job. Looks like Github was having an issue. It may be a permissions issue if you don't see a button like this in the upper right corner to rerun jobs. I'm not sure though. If you want a workaround, I believe you can push an empty commit and that should trigger all the Github actions again: The commit messages get squashed on a merge to main anyways. |
… github.com:k8port/human-essentials into 4859-lower-pagination-threshold-for-staging-and-dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bin/lint run locally:
Running erb_lint
warning: parser/current is loading parser/ruby32, which recognizes 3.2.6-compliant syntax, but you are running 3.2.2.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Linting and autocorrecting 426 files with 14 linters (11 autocorrectable)…
pushed empty commit message to trigger new build
@@ -1,6 +1,10 @@ | |||
# frozen_string_literal: true | |||
Kaminari.configure do |config| | |||
config.default_per_page = 50 | |||
if Rails.env.development? || Rails.env.staging? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also think of making this configurable from env config? Does this makes sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true - we could move this to development.rb
and staging.rb
which is a bit neater. But I wouldn't block the PR for that.
@k8port: Your PR |
Resolves #4859 lower threshold on pagination in dev and staging
Description
This change sets the pagination threshold to 5 in dev and staging environments while leaving it at 50 otherwise. This is to ease manual testing by having fewer objects per page.
Guide questions:
List any dependencies that are required for this change. (gems, 🤩 libraries, etc.). kaminari
Include anything else we should know about. -->
This change only affects kaminari configuration. Controllers not already implementing kaminari pagination are not affected. Pagination configuration in kaminari_config.rb, for example, is not being applied to the Base Items index view.
Here is the relevant code (app/controllers/admin/base_items_controller.rb, line 21):
app/views/admin/base_items/index.html.erb view is not using pagination at all - just rendering all items directly.
Base Items listing does not use Kaminari's pagination. To fix, the controller and view would need to implement kaminarri pagination (base_items_controller.rb):
a index
Now the Base Items listing should show only 5 items per page in development and staging environments, with pagination controls to navigate between pages. The changes I made:
Modified the controller to use Kaminari's page method
Added the paginate helper to the view to show pagination controls
These changes will make the Base Items listing respect the pagination settings we configured in kaminari_config.rb. You should now see:
5 items per page in development/staging
50 items per page in production
Pagination controls at the bottom of the list to navigate between pages
The reason this wasn't working before is that the Base Items listing wasn't using Kaminari's pagination features at all - it was just showing all items at once with BaseItem.alphabetized.all. Now it's properly integrated with the pagination system.
Type of change
How Has This Been Tested?
Unit test to verify pagination according to env.
To run unit test:
bundle exec rspec spec/lib/kaminari_config_spec.rb
Do we need to do anything else to verify your changes?
No