-
Notifications
You must be signed in to change notification settings - Fork 172
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
Including users and groups when loading user_roles #9550
Including users and groups when loading user_roles #9550
Conversation
# Paginating the list by sending only first 100 elements unless mentioned in the API. | ||
paginate json: roles |
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.
This change seems like it was included in your previous pagination PR.
Is there maybe a chance you didn't include the latest changes from main
in your currentPR branch?
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.
Oops I don't know how this came, removed now.
@@ -19,6 +19,9 @@ class Api::V0::UserRolesController < Api::V0::ApiController | |||
group_id = params[:groupId] | |||
user_id = params[:userId] | |||
|
|||
# For post filtering, user & group is needed. | |||
active_record = active_record.includes([:user, :group]) |
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.
First, includes
takes varargs, so .includes(:user, :group)
will work.
Second, if you know that these two are going to be includes
'd anyways no matter what, then you can just declare active_record = UserRole.includes(...)
directly at the top of the method above.
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.
Oh ya, thanks for that. Implemented.
030552d
to
0fa4ab4
Compare
0fa4ab4
to
fc0bae2
Compare
The user data and group data is used for post filtering, hence precomputing them for the roles list API.