Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-15 06:12:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-15 06:12:21 +0300
commitcf77519faca7a24921def7cce66947e274195c6c (patch)
treecd251f0e7250a207ef55ecebaff12af26d7be62f /app
parentd9749000e7835a56d960b4768abe783dca37f37e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/finders/ci/pipelines_for_merge_request_finder.rb64
1 files changed, 12 insertions, 52 deletions
diff --git a/app/finders/ci/pipelines_for_merge_request_finder.rb b/app/finders/ci/pipelines_for_merge_request_finder.rb
index 839ec417cd4..b623a94541b 100644
--- a/app/finders/ci/pipelines_for_merge_request_finder.rb
+++ b/app/finders/ci/pipelines_for_merge_request_finder.rb
@@ -31,67 +31,27 @@ module Ci
# Fetch all pipelines without permission check.
def all
- ::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336891') do
- strong_memoize(:all_pipelines) do
- next Ci::Pipeline.none unless source_project
+ strong_memoize(:all_pipelines) do
+ next Ci::Pipeline.none unless source_project
- pipelines =
- if merge_request.persisted?
- all_pipelines_for_merge_request
- else
- triggered_for_branch.for_sha(commit_shas)
- end
+ pipelines =
+ if merge_request.persisted?
+ all_pipelines_for_merge_request
+ else
+ triggered_for_branch.for_sha(commit_shas)
+ end
- pipelines = pipelines.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336891')
-
- sort(pipelines)
- end
+ sort(pipelines)
end
end
private
- # rubocop: disable CodeReuse/ActiveRecord
- def pipelines_using_cte
- sha_relation = merge_request.all_commits.select(:sha).distinct
-
- cte = Gitlab::SQL::CTE.new(:shas, sha_relation)
-
- pipelines_for_merge_requests = triggered_by_merge_request
- pipelines_for_branch = filter_by_sha(triggered_for_branch, cte)
-
- Ci::Pipeline.with(cte.to_arel) # rubocop: disable CodeReuse/ActiveRecord
- .from_union([pipelines_for_merge_requests, pipelines_for_branch])
- end
- # rubocop: enable CodeReuse/ActiveRecord
-
- def filter_by_sha(pipelines, cte)
- hex = Arel::Nodes::SqlLiteral.new("'hex'")
- string_sha = Arel::Nodes::NamedFunction.new('encode', [cte.table[:sha], hex])
- join_condition = string_sha.eq(Ci::Pipeline.arel_table[:sha])
-
- filter_by(pipelines, cte, join_condition)
- end
-
- def filter_by(pipelines, cte, join_condition)
- shas_table =
- Ci::Pipeline.arel_table
- .join(cte.table, Arel::Nodes::InnerJoin)
- .on(join_condition)
- .join_sources
-
- pipelines.joins(shas_table) # rubocop: disable CodeReuse/ActiveRecord
- end
-
def all_pipelines_for_merge_request
- if Feature.enabled?(:decomposed_ci_query_in_pipelines_for_merge_request_finder, target_project, default_enabled: :yaml)
- pipelines_for_merge_request = triggered_by_merge_request
- pipelines_for_branch = triggered_for_branch.for_sha(recent_diff_head_shas(COMMITS_LIMIT))
+ pipelines_for_merge_request = triggered_by_merge_request
+ pipelines_for_branch = triggered_for_branch.for_sha(recent_diff_head_shas(COMMITS_LIMIT))
- Ci::Pipeline.from_union([pipelines_for_merge_request, pipelines_for_branch])
- else
- pipelines_using_cte
- end
+ Ci::Pipeline.from_union([pipelines_for_merge_request, pipelines_for_branch])
end
# NOTE: this method returns only parent merge request pipelines.