Commit fac427db authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'use-cached-project-count' into 'master'

Used cached value of project count to reduce DB load

Requires gitlab-org/gitlab-ce!5746

Possible fix for gitlab-com/infrastructure#303

See merge request !637
parents a998cab1 563495a5
...@@ -6,6 +6,7 @@ v 8.11.0 (unreleased) ...@@ -6,6 +6,7 @@ v 8.11.0 (unreleased)
- [Elastic][Fix] Commit search breaks for some URLs on gitlab-ce project - [Elastic][Fix] Commit search breaks for some URLs on gitlab-ce project
v 8.10.5 (unreleased) v 8.10.5 (unreleased)
- Used cached value of project count to reduce DB load
v 8.10.4 v 8.10.4
- Fix available users in userselect dropdown when there is more than one userselect on the page. !604 (Rik de Groot) - Fix available users in userselect dropdown when there is more than one userselect on the page. !604 (Rik de Groot)
......
...@@ -12,7 +12,7 @@ module Elastic ...@@ -12,7 +12,7 @@ module Elastic
end end
def self.repositories_count def self.repositories_count
Project.count Project.cached_count
end end
def client_for_indexing def client_for_indexing
......
...@@ -408,6 +408,12 @@ class Project < ActiveRecord::Base ...@@ -408,6 +408,12 @@ class Project < ActiveRecord::Base
joins(join_body).reorder('join_note_counts.amount DESC') joins(join_body).reorder('join_note_counts.amount DESC')
end end
def cached_count
Rails.cache.fetch('total_project_count', expires_in: 5.minutes) do
Project.count
end
end
end end
def repository_storage_path def repository_storage_path
......
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
%h4 Projects %h4 Projects
.data .data
= link_to admin_namespaces_projects_path do = link_to admin_namespaces_projects_path do
%h1= number_with_delimiter(Project.count) %h1= number_with_delimiter(Project.cached_count)
%hr %hr
= link_to('New Project', new_project_path, class: "btn btn-new") = link_to('New Project', new_project_path, class: "btn btn-new")
.col-sm-4 .col-sm-4
......
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