Resolve "More N+1s in calculating notification recipients"
What does this MR do?
Fixes a few more N+1s in the NotificationRecipientService.
Using the example in the issue:
# paste the contents of https://gitlab.com/gitlab-org/gitlab-ce/blob/master/spec/support/helpers/query_recorder.rb
merge_request = MergeRequest.find(8845120)
user = User.find_by_username('smcgivern')
record = ActiveRecord::QueryRecorder.new { NotificationRecipientService.build_recipients(merge_request, user, action: "resolve_all_discussions") }
record.count
#=> 733
Then, pasting in these changes:
record = ActiveRecord::QueryRecorder.new { NotificationRecipientService.build_recipients(merge_request, user, action: "resolve_all_discussions") }
record.count
#=> 396
# Most of the remainder are license queries!
# This project isn't private, so doesn't benefit from the second commit.
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides
Closes #47496 (closed)
Edited by Sean McGivern