From 42062a454a650d81d9fe6dddde7b39b056ec0a88 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 24 Aug 2017 18:17:04 +0200 Subject: Re-use issue/MR counts for the pagination system This changes the issue and MR index pages so the pagination system re-uses the output of the COUNT(*) query used to calculate the number of rows per state (opened, closed, etc). This removes the need for an additional COUNT(*) on both pages. --- app/finders/issuable_finder.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/finders') diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index c8dd2275730..9848497f258 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -61,6 +61,10 @@ class IssuableFinder execute.find_by(*params) end + def row_count + Gitlab::IssuablesCountForState.new(self).for_state_or_opened(params[:state]) + end + # We often get counts for each state by running a query per state, and # counting those results. This is typically slower than running one query # (even if that query is slower than any of the individual state queries) and -- cgit v1.2.3