summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-05-25 14:28:16 -0700
committerStan Hu <stanhu@gmail.com>2018-05-25 22:58:43 -0700
commitb6125f7045d2bed4aadf798dde4c547e2047e039 (patch)
treed8e522ca729b2f755229a6fea2fa0fa9833f154e /app/controllers
parent50c8ed2bf498c69d3d52ba1451274e3fbf438429 (diff)
downloadgitlab-ce-b6125f7045d2bed4aadf798dde4c547e2047e039.tar.gz
Fix fast admin counters not working when PostgreSQL has secondariessh-fix-admin-page-counts-take-2
This commit does a number of things: 1. Reduces the number of queries needed by perform a single query to get all the tuples for the relevant rows. 2. Uses a transaction to query the tuple counts to ensure that the data is retrieved from the primary. Closes #46742
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/dashboard_controller.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
index d6a6bc7d4a1..737942f3eb2 100644
--- a/app/controllers/admin/dashboard_controller.rb
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -1,7 +1,11 @@
class Admin::DashboardController < Admin::ApplicationController
include CountHelper
+ COUNTED_ITEMS = [Project, User, Group, ForkedProjectLink, Issue, MergeRequest,
+ Note, Snippet, Key, Milestone].freeze
+
def index
+ @counts = Gitlab::Database::Count.approximate_counts(COUNTED_ITEMS)
@projects = Project.order_id_desc.without_deleted.with_route.limit(10)
@users = User.order_id_desc.limit(10)
@groups = Group.order_id_desc.with_route.limit(10)