Skip to content

Add ActiveRecord associations for project and namespace mirrors

What does this MR do and why?

This MR is a follow-up from !140964 (comment 1714595507). It adds associations to the mirror classes so that we don't need to disable a Rubocop rule.

Part of #426113 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

n/a

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

> Ci::Build.all.limit(10).left_outer_joins(:runner, :runner_manager, :project_mirror => :namespace_mirror).select(:finished_at, "#{::Ci::NamespaceMirror.table_name}.traversal_ids[1] AS root_namespace_id").to_a

  Ci::Build Load (4.5ms)  SELECT "p_ci_builds"."finished_at", ci_namespace_mirrors.traversal_ids[1] AS root_namespace_id
FROM "p_ci_builds"
  LEFT OUTER JOIN "ci_runners" ON "ci_runners"."id" = "p_ci_builds"."runner_id"
  LEFT OUTER JOIN "p_ci_runner_machine_builds" ON "p_ci_runner_machine_builds"."build_id" = "p_ci_builds"."id"
  LEFT OUTER JOIN "ci_runner_machines" ON "ci_runner_machines"."id" = "p_ci_runner_machine_builds"."runner_machine_id"
  LEFT OUTER JOIN "ci_project_mirrors" ON "ci_project_mirrors"."project_id" = "p_ci_builds"."project_id"
  LEFT OUTER JOIN "ci_namespace_mirrors" ON "ci_namespace_mirrors"."namespace_id" = "ci_project_mirrors"."namespace_id"
WHERE "p_ci_builds"."type" = 'Ci::Build'
LIMIT 10 /*application:console,db_config_name:ci,console_hostname:gitlab-macbookpro.work.pombei.ro,console_username:pedropombeiro,line:(pry):35:in `__pry__'*/

Merge request reports