summaryrefslogtreecommitdiff
path: root/app/controllers/search_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r--app/controllers/search_controller.rb34
1 files changed, 6 insertions, 28 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index c92b3457640..196b1887ca7 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -3,16 +3,8 @@
class SearchController < ApplicationController
include ControllerWithCrossProjectAccessCheck
include SearchHelper
- include RendersCommits
include RedisTracking
- SCOPE_PRELOAD_METHOD = {
- projects: :with_web_entity_associations,
- issues: :with_web_entity_associations,
- merge_requests: :with_web_entity_associations,
- epics: :with_web_entity_associations
- }.freeze
-
track_redis_hll_event :show, name: 'i_search_total', feature: :search_track_unique_users, feature_default_enabled: true
around_action :allow_gitaly_ref_name_caching
@@ -41,14 +33,12 @@ class SearchController < ApplicationController
@search_term = params[:search]
@sort = params[:sort] || default_sort
- @scope = search_service.scope
- @show_snippets = search_service.show_snippets?
- @search_results = search_service.search_results
- @search_objects = search_service.search_objects(preload_method)
- @search_highlight = search_service.search_highlight
-
- render_commits if @scope == 'commits'
- eager_load_user_status if @scope == 'users'
+ @search_service = Gitlab::View::Presenter::Factory.new(search_service, current_user: current_user).fabricate!
+ @scope = @search_service.scope
+ @show_snippets = @search_service.show_snippets?
+ @search_results = @search_service.search_results
+ @search_objects = @search_service.search_objects
+ @search_highlight = @search_service.search_highlight
increment_search_counters
end
@@ -79,10 +69,6 @@ class SearchController < ApplicationController
private
- def preload_method
- SCOPE_PRELOAD_METHOD[@scope.to_sym]
- end
-
# overridden in EE
def default_sort
'created_desc'
@@ -102,14 +88,6 @@ class SearchController < ApplicationController
true
end
- def render_commits
- @search_objects = prepare_commits_for_rendering(@search_objects)
- end
-
- def eager_load_user_status
- @search_objects = @search_objects.eager_load(:status) # rubocop:disable CodeReuse/ActiveRecord
- end
-
def check_single_commit_result?
return false if params[:force_search_results]
return false unless @project.present?