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:29:52 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-05-22 13:29:52 +0300
commit9520d2ff278f12cf2e01a755b1ea12213fd22edb (patch)
treef2c9a782cee1567b406d92f11f763292238f3b8a /app/models/project.rb
parent631bd9bf082c396059867d512fcfbdc80445c65e (diff)
Memoize project active runners to avoid N+1 queries
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 50b8a9a95ea..5943a929364 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1418,7 +1418,9 @@ class Project < ActiveRecord::Base
end
def any_runners?(&block)
- all_runners.active.any?(&block)
+ @active_runners ||= all_runners.active
+
+ @active_runners.any?(&block)
end
def valid_runners_token?(token)