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:
authorJosh Frye <joshfng@gmail.com>2016-05-31 15:51:13 +0300
committerJosh Frye <joshfng@gmail.com>2016-06-02 18:10:57 +0300
commit2d05de7af8de9a11f5bdfec0dd3f294a0148d023 (patch)
tree2e09d46ea3c28ee4233003b5f4d5c73efbec75b3 /app/models/project.rb
parent81621e46e74e2099fe5b8a25553728aaee08e129 (diff)
Cache project build count. Closes #18032
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 525a82c7534..1375dab8c34 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1011,4 +1011,10 @@ class Project < ActiveRecord::Base
update_attribute(:pending_delete, true)
end
+
+ def running_or_pending_build_count
+ Rails.cache.fetch(['projects', id, 'running_or_pending_build_count'], expires_in: 60) do
+ builds.running_or_pending.count(:all)
+ end
+ end
end