-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
For super admin, add pagination on /admin/enterprises
#10322
For super admin, add pagination on /admin/enterprises
#10322
Conversation
56230be
to
5b83429
Compare
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.
Nice quick fix!
|
||
# These need to run before #load_resource so that @object is initialised with sanitised values | ||
prepend_before_action :override_owner, only: :create | ||
prepend_before_action :override_sells, only: :create | ||
|
||
before_action :load_enterprise_set, only: :index | ||
before_action :load_enterprise_set_on_index, only: :index |
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.
When something is happening only in one action, I often prefer to call it within that action. It keeps related code together and you can see quicker what's happening.
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.
I agree 👍
84e2fbc
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.
Great, I can't wait to see this in action!
Enterprises are stored in `@enterprise_set` variables, and we iterate over to show the list of enterprises to super admin. Previously, we used to use `Sets::EnterpriseSet.new(collection)` instead of creating set based on `@collection`: this leads to call the `collection` method twice, which was probably very time consuming. This commit fix also that. + use paginated enterprises loading on bulk update but without testing if the current user is an admin
so let's call it inside the action.
84e2fbc
to
9b2ed88
Compare
@pagy, @paginated_collection = pagy(@collection) | ||
@enterprise_set = Sets::EnterpriseSet.new(@paginated_collection, params) |
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.
I guess that @paginated_collection
is not used anywhere else in the code. So by making it a local variable, it's clear that you can change the name or do whatever you like without affected other code.
On the other hand, this variable may be useful at some point. And if we publicise @pagy
then why not the collection? So I don't mind this version either. It looks more consistent.
Hi @jibees, Before stagingAs super admin user (loading takes like forever): After stagingResults
Note
Thanks! I think this is ready to merge! 🥳 |
What? Why?
Introducing pagination thanks to
pagy
for super admin on this page.Also, previously, we used to use
@enterprise_set = Sets::EnterpriseSet.new(collection)
instead of creating set based on@collection
: this leads to call thecollection
method twice, which was probably very time consuming. This commit fix also that.What should we test?
/admin/enterprises
. In term of performance, actually, I don't know if this could be mesurable in staging. Maybe we could compare the request time of/admin/enterprises
URL via chrome|firefox inspector.Release notes
Changelog Category: User facing changes
The title of the pull request will be included in the release notes.