Skip to content

Fix n+1 on fetching counts in User -> Groups page

What does this MR do and why?

Fixes #436012 (closed)

As mentioned in the issue, this MR aims to fix the n+1 happening in user's groups page. The n+1 arises when trying to fetch the count of non-archived projects and non-invite members.

  • Remove N+1 from group.projects.non_archived.count
  • Remove N+1 from group.members.non_invite.count
  • Add test to assert that no N+1 is happening during the execution of the controller action. Example
  • Model specs for new associations that are introduced
  • Model specs for new with_* scopes that are introduced. Example

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Bijoy Sijo

Merge request reports