Improve N+1 preloading for when boundary_type is aliased / not a direct association
The following discussion from !242438 (merged) should be addressed:
-
@alexbuijs started a discussion: (+1 comment)
This silently no-ops for a couple of common list types, so the N+1 we're fixing still happens for them:
MergeRequestTypedeclaresboundary: :project, but that'salias_method :project, :target_project—reflect_on_association(:project)isnil(the reflection is:target_project). It also usespresent_using MergeRequestPresenter, so it's already skipped at therespond_to?(:reflect_on_association)guard on L59.Ci::RunnerType'sboundary: :owneris adef owner, not an association.
Only
projectshas an N+1 regression test, so MR/runner lists aren't covered. Could we handle aliased / presenter-wrapped boundaries here (e.g. declaringboundary: :target_project)?
Possible solutions
MergeRequestType-> so if we were to changeboundary_method: :target_project, that would be okay?Ci::RunnerType-> We can extend the preloading to use the directive:
authorize_granular_token(
permissions: :read_runner,
boundaries: [...],
preload: [{ owner_runner_project: :project }, { owner_runner_namespace: :namespace }, :creator]
)Edited by 🤖 GitLab Bot 🤖