Fix N+1 for global/group notes search
What does this MR do and why?
Background
Found when working on !112369 (merged)
The spec was reporting as a flaky spec, I decided to fix in a separate MR. The notes scope wasn't changed as part of the original MR so the changes were not related.
failed pipeline: https://gitlab.com/gitlab-org/gitlab/-/jobs/3883576313
The failed pipeline is repeatable locally with the seed
bundle exec rspec ee/spec/requests/search_controller_spec.rb --seed 5857 --format documentation --fail-fast
Fix
The failed pipeline showed extra failures for loading group (unknown) AND namespace routes (known). This MR adds preloading for the namespace routes and group for each note and updates the controller specs.
Note: The fix is only implemented for EE because the issue shows up on global and group scoped notes searches. Global/group notes searches are not available in CE. Discussion: !113770 (comment 1302976345)
Screenshots or screen recordings
N/A
How to set up and validate locally
I used the rspec test with seed to verify this is fixed
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.