Skip to content

Preload user status for mentioning users

Adam Hegyi requested to merge 285442-preload-user-status-for-mentions into master

What does this MR do?

Preload user status for mentioning users

This change uses BatchLoader to efficiently preload UserStatus.availability for several different user arrays to avoid N+1 queries.

Verification

I used a DB lab PRD instance to verify if the N+1 query is gone and the preloading logic works.

Project:

project = Project.find(278964)
current_user = User.find_by_username("ahegyi")
target = MergeRequest.where(project_id: 278964, iid: 1646).first!

puts ::Projects::ParticipantsService.new(project, current_user).execute(target)

Group:

current_user = User.find_by_username("ahegyi")
group = Group.find(9970)
target = Epic.where(group_id: 9970, iid: 1533).first!

puts ::Groups::ParticipantsService.new(group, current_user).execute(target)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #285442 (closed)

Edited by Adam Hegyi

Merge request reports

Loading