Commit 2d05de7a authored by Josh Frye's avatar Josh Frye

Cache project build count. Closes #18032

parent 81621e46
...@@ -1011,4 +1011,10 @@ class Project < ActiveRecord::Base ...@@ -1011,4 +1011,10 @@ class Project < ActiveRecord::Base
update_attribute(:pending_delete, true) update_attribute(:pending_delete, true)
end 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 end
...@@ -52,6 +52,15 @@ ...@@ -52,6 +52,15 @@
= icon('ship fw') = icon('ship fw')
%span %span
Pipelines 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 - if project_nav_tab? :container_registry
= nav_link(controller: %w(container_registry)) do = nav_link(controller: %w(container_registry)) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment