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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-14 00:09:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-14 00:09:54 +0300
commit79ecd9a7489305e8357ca1df74ac7d7cc775b0d3 (patch)
tree28ba38ec1b11d580386cdda4930536566dac992d /lib/gitlab/data_builder
parentc575d3cfde0cba06c37d5a5dae0ca7288f68f1e3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/data_builder')
-rw-r--r--lib/gitlab/data_builder/pipeline.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/gitlab/data_builder/pipeline.rb b/lib/gitlab/data_builder/pipeline.rb
index b8ccef03e63..385f1e57705 100644
--- a/lib/gitlab/data_builder/pipeline.rb
+++ b/lib/gitlab/data_builder/pipeline.rb
@@ -19,18 +19,40 @@ module Gitlab
user: pipeline.user.try(:hook_attrs),
project: pipeline.project.hook_attrs(backward: false),
commit: pipeline.commit.try(:hook_attrs),
- builds: Gitlab::Lazy.new { pipeline.builds.latest.map(&method(:build_hook_attrs)) }
+ builds: Gitlab::Lazy.new do
+ preload_builds(pipeline, :latest_builds)
+ pipeline.latest_builds.map(&method(:build_hook_attrs))
+ end
)
end
def with_retried_builds
merge(
- builds: Gitlab::Lazy.new { @pipeline.builds.map(&method(:build_hook_attrs)) }
+ builds: Gitlab::Lazy.new do
+ preload_builds(@pipeline, :builds)
+ @pipeline.builds.map(&method(:build_hook_attrs))
+ end
)
end
private
+ # rubocop: disable CodeReuse/ActiveRecord
+ def preload_builds(pipeline, association)
+ ActiveRecord::Associations::Preloader.new.preload(pipeline,
+ {
+ association => {
+ **::Ci::Pipeline::PROJECT_ROUTE_AND_NAMESPACE_ROUTE,
+ runner: :tags,
+ job_artifacts_archive: [],
+ user: [],
+ metadata: []
+ }
+ }
+ )
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+
def hook_attrs(pipeline)
{
id: pipeline.id,