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:
authorKamil TrzciƄski <ayufan@ayufan.eu>2017-11-21 21:15:51 +0300
committerOswaldo Ferreira <oswaldo@gitlab.com>2017-11-23 04:58:25 +0300
commitc7fcad8e4b10bc0a09b0c5ae954a5f856bed3cbe (patch)
tree42527864bbbbf574a76644e6412825e7b75b1652 /app
parentb5343c3065da52550ee4893cc82c00c4af85dda1 (diff)
Merge branch 'reduce-queries-for-artifacts-button' into 'master'
Use arrays in Ci::Pipeline#latest_builds_with_artifacts See merge request gitlab-org/gitlab-ce!15525 (cherry picked from commit ce019812a5127d503c735f5fe870e2aa4ad14665) 54f1e406 Use arrays in Pipeline#latest_builds_with_artifacts
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 797a12d4e63..ec12dd7c210 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -505,7 +505,10 @@ module Ci
end
def latest_builds_with_artifacts
- @latest_builds_with_artifacts ||= builds.latest.with_artifacts
+ # We purposely cast the builds to an Array here. Because we always use the
+ # rows if there are more than 0 this prevents us from having to run two
+ # queries: one to get the count and one to get the rows.
+ @latest_builds_with_artifacts ||= builds.latest.with_artifacts.to_a
end
private