diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 2fb83f949..8038e033f 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -225,14 +225,12 @@ class SearchController < ApplicationController def quick results = if params[:filter].present? - object_quick_search(params[:filter].singularize, - search_by_id: Constants::QUICK_SEARCH_SEARCHABLE_BY_NAME - .exclude?(params[:filter].singularize)) + object_quick_search(params[:filter].singularize) else Constants::QUICK_SEARCH_SEARCHABLE_OBJECTS.filter_map do |object| next if object == 'label_template' && !LabelTemplate.enabled? - object_quick_search(object, search_by_id: Constants::QUICK_SEARCH_SEARCHABLE_BY_NAME.exclude?(object)) + object_quick_search(object) end.flatten.sort_by(&:updated_at).reverse.take(Constants::QUICK_SEARCH_LIMIT) end @@ -241,8 +239,9 @@ class SearchController < ApplicationController private - def object_quick_search(class_name, search_by_id: true) - search_method = class_name.to_s.camelize.constantize.method(search_by_id ? :search_by_name_and_id : :search_by_name) + def object_quick_search(class_name) + search_model = class_name.to_s.camelize.constantize + search_method = search_model.method(search_model.respond_to?(:code) ? :search_by_name_and_id : :search_by_name) search_method.call(current_user, current_team, diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index 4d7aa80dd..bdbeb7812 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -447,7 +447,6 @@ class Constants QUICK_SEARCH_LIMIT = 5 QUICK_SEARCH_SEARCHABLE_OBJECTS = %w(project experiment my_module protocol repository_row report project_folder result label_template).freeze - QUICK_SEARCH_SEARCHABLE_BY_NAME = %w(project_folder result label_template).freeze # ) \ / ( # /|\ )\_/( /|\