Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koller <mkoller@gitlab.com>2019-07-15 20:59:57 +0300
committerMarkus Koller <mkoller@gitlab.com>2019-08-12 23:01:15 +0300
commit49c83155ccb78284b17a9ffa47583ddace5dbd01 (patch)
treef9b5697ef11d581737d07b395f529ef3d20e1325 /app/controllers/search_controller.rb
parent71ec793214dd81701b5485aa10e20c9719cb0584 (diff)
Load search result counts asynchronously
Querying all counts for the different search results in the same request led to timeouts, so we now only calculate the count for the *current* search results, and request the others in separate asynchronous calls.
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r--app/controllers/search_controller.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 13741548687..e30935be4b6 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -36,6 +36,15 @@ class SearchController < ApplicationController
check_single_commit_result
end
+ def count
+ params.require([:search, :scope])
+
+ scope = search_service.scope
+ count = search_service.search_results.formatted_count(scope)
+
+ render json: { count: count }
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
def autocomplete
term = params[:term]