Remove .becomes(Namespace) calls that favour N+1 queries on route model
What does this MR do?
This MR removes usages of project.namespace.becomes(Namespace)
, that were often causing N+1 queries even though routes were eagerly preloaded in advance. This should help reduce those N+1 in multiple places.
This makes use of the https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/12566
change which makes it possible to build project routes without having to pass in namespace, so just removing the project.namespace.becomes(Namespace)
should work re #20471 (closed)
Also this MR adds a rubocop rule to avoid using .becomes(SomeConstant)
as it would usually generate N+1 queries issues down the line.
re #23182 (closed), #20471 (closed)
Screenshots
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