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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-05-22 13:30:45 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-05-22 13:30:45 +0300
commit6c63f96e0a26fa046fb0cc4664240e37db8b37d8 (patch)
tree60665118a4d454b2d68c4c15a6f76912b3763c4f /lib/gitlab/ci/pipeline/preloader.rb
parent9520d2ff278f12cf2e01a755b1ea12213fd22edb (diff)
Preload number of warnings in every stage in a pipeline
This makes it possible to avoid N+1 queries when loading pipelines table.
Diffstat (limited to 'lib/gitlab/ci/pipeline/preloader.rb')
-rw-r--r--lib/gitlab/ci/pipeline/preloader.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/gitlab/ci/pipeline/preloader.rb b/lib/gitlab/ci/pipeline/preloader.rb
index 36a19719802..2f792062124 100644
--- a/lib/gitlab/ci/pipeline/preloader.rb
+++ b/lib/gitlab/ci/pipeline/preloader.rb
@@ -6,7 +6,7 @@ module Gitlab
# Class for preloading data associated with pipelines such as commit
# authors.
module Preloader
- def self.preload(project, pipelines)
+ def self.preload(pipelines)
# This ensures that all the pipeline commits are eager loaded before we
# start using them.
pipelines.each(&:commit)
@@ -20,6 +20,11 @@ module Gitlab
# that Ci::Pipeline#has_warnings? doesn't execute any additional
# queries.
pipeline.number_of_warnings
+
+ # This preloads the number of warnings for every stage, ensuring
+ # that Ci::Stage#has_warnings? doesn't execute any additional
+ # queries.
+ pipeline.stages.each { |stage| stage.number_of_warnings }
end
end
end