Commit 48359ce1 authored by lauraMon's avatar lauraMon

Removes cross-joins FF in MergeRequest#environements

Changelog: changed
parent 5ead4e2f
......@@ -1409,19 +1409,15 @@ class MergeRequest < ApplicationRecord
def environments
return Environment.none unless actual_head_pipeline&.merge_request?
if ::Feature.enabled?(:avoid_cross_joins_environments_merge_request, default_enabled: :yaml)
build_for_actual_head_pipeline = Ci::Build.latest.where(pipeline: actual_head_pipeline)
build_for_actual_head_pipeline = Ci::Build.latest.where(pipeline: actual_head_pipeline)
environments = build_for_actual_head_pipeline.joins(:metadata)
.where.not('ci_builds_metadata.expanded_environment_name' => nil)
.distinct('ci_builds_metadata.expanded_environment_name')
.limit(100)
.pluck(:expanded_environment_name)
environments = build_for_actual_head_pipeline.joins(:metadata)
.where.not('ci_builds_metadata.expanded_environment_name' => nil)
.distinct('ci_builds_metadata.expanded_environment_name')
.limit(100)
.pluck(:expanded_environment_name)
Environment.where(project: project, name: environments)
else
actual_head_pipeline.environments
end
Environment.where(project: project, name: environments)
end
def fetch_ref!
......
---
name: avoid_cross_joins_environments_merge_request
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71591
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343236
milestone: '14.5'
type: development
group: group::sharding
default_enabled: false
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment