diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-14 00:09:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-14 00:09:54 +0300 |
commit | 79ecd9a7489305e8357ca1df74ac7d7cc775b0d3 (patch) | |
tree | 28ba38ec1b11d580386cdda4930536566dac992d /lib/gitlab/data_builder | |
parent | c575d3cfde0cba06c37d5a5dae0ca7288f68f1e3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/data_builder')
-rw-r--r-- | lib/gitlab/data_builder/pipeline.rb | 26 |
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, |