diff options
author | Josh Frye <joshfng@gmail.com> | 2016-05-31 08:51:13 -0400 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-06-01 15:03:53 -0400 |
commit | 15157e1f08ae1e15628cd682c39697cd1be4e834 (patch) | |
tree | 1174779be5188256813b147a31fddb9c383b39c0 | |
parent | e9bb895b5ac639bcb4166b23b796566f0320741a (diff) | |
download | gitlab-ce-15157e1f08ae1e15628cd682c39697cd1be4e834.tar.gz |
Cache project build count. Closes #18032
-rw-r--r-- | .vagrant_enabled | 0 | ||||
-rw-r--r-- | app/models/project.rb | 6 | ||||
-rw-r--r-- | app/views/layouts/nav/_project.html.haml | 9 |
3 files changed, 15 insertions, 0 deletions
diff --git a/.vagrant_enabled b/.vagrant_enabled new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/.vagrant_enabled diff --git a/app/models/project.rb b/app/models/project.rb index c1d9bae44c9..42982b1e1e9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1007,4 +1007,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 diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml index 2c9b9006668..86d2ba9ba26 100644 --- a/app/views/layouts/nav/_project.html.haml +++ b/app/views/layouts/nav/_project.html.haml @@ -52,6 +52,15 @@ = icon('ship fw') %span Pipelines + %span.badge.count.ci_counter= number_with_delimiter(@project.ci_commits.running_or_pending.count) + + - if project_nav_tab? :builds + = nav_link(controller: %w(builds)) do + = link_to project_builds_path(@project), title: 'Builds', class: 'shortcuts-builds' do + = icon('cubes fw') + %span + Builds + %span.badge.count.builds_counter= number_with_delimiter(@project.running_or_pending_build_count) - if project_nav_tab? :container_registry = nav_link(controller: %w(container_registry)) do |