Preload user status for mentioning users
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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