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

Including users and groups when loading user_roles #9550

Merged
merged 2 commits into from
Jun 24, 2024

Conversation

danieljames-dj
Copy link
Member

The user data and group data is used for post filtering, hence precomputing them for the roles list API.

Comment on lines 53 to 54
# Paginating the list by sending only first 100 elements unless mentioned in the API.
paginate json: roles
Copy link
Member

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?

Copy link
Member Author

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])
Copy link
Member

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.

Copy link
Member Author

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.

@danieljames-dj danieljames-dj merged commit d9a6f92 into thewca:main Jun 24, 2024
1 check passed
@danieljames-dj danieljames-dj deleted the precompute-users-groups branch June 24, 2024 01:12
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.

None yet

2 participants