Skip to content

Remove .becomes(Namespace) calls that favour N+1 queries on route model

Alexandru Croitor requested to merge remove-namespace-becomes-namespace into master

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

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
Edited by Alexandru Croitor

Merge request reports