Refactor Organization scope for getting Organizations by users
What does this MR do and why?
This is a small refactor that will allow for more flexibility for retrieving organizations that belong to a certain user.
Follow-up from !158626 (comment 2010176114)
Query Plans
- Scope
Organizations::Organization.with_user(user)
- Master branch: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/30197/commands/93638
- This branch: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/30197/commands/93636
- Query is more efficient because the join on
users
table is now removed
- Scope
Organizations::OrganizationUser.by_user
- Master branch: N/A
- This branch: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/30197/commands/93637
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #443829 (closed)
Edited by Rutger Wessels