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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/controllers/search_controller.rb
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r--app/controllers/search_controller.rb31
1 files changed, 13 insertions, 18 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 04d2b3068da..217f08dd648 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -5,6 +5,10 @@ class SearchController < ApplicationController
include SearchHelper
include RendersCommits
+ SCOPE_PRELOAD_METHOD = {
+ projects: :with_web_entity_associations
+ }.freeze
+
around_action :allow_gitaly_ref_name_caching
skip_before_action :authenticate_user!
@@ -28,12 +32,12 @@ class SearchController < ApplicationController
@scope = search_service.scope
@show_snippets = search_service.show_snippets?
@search_results = search_service.search_results
- @search_objects = search_service.search_objects
+ @search_objects = search_service.search_objects(preload_method)
render_commits if @scope == 'commits'
eager_load_user_status if @scope == 'users'
- increment_navbar_searches_counter
+ increment_search_counters
check_single_commit_result
end
@@ -47,22 +51,11 @@ class SearchController < ApplicationController
render json: { count: count }
end
- # rubocop: disable CodeReuse/ActiveRecord
- def autocomplete
- term = params[:term]
-
- if params[:project_id].present?
- @project = Project.find_by(id: params[:project_id])
- @project = nil unless can?(current_user, :read_project, @project)
- end
-
- @ref = params[:project_ref] if params[:project_ref].present?
+ private
- render json: search_autocomplete_opts(term).to_json
+ def preload_method
+ SCOPE_PRELOAD_METHOD[@scope.to_sym]
end
- # rubocop: enable CodeReuse/ActiveRecord
-
- private
def search_term_valid?
unless search_service.valid_query_length?
@@ -98,9 +91,11 @@ class SearchController < ApplicationController
end
end
- def increment_navbar_searches_counter
+ def increment_search_counters
+ Gitlab::UsageDataCounters::SearchCounter.count(:all_searches)
+
return if params[:nav_source] != 'navbar'
- Gitlab::UsageDataCounters::SearchCounter.increment_navbar_searches_count
+ Gitlab::UsageDataCounters::SearchCounter.count(:navbar_searches)
end
end