def call
      search_results = Decidim::Searchable.searchable_resources.inject({}) do |results_by_type, (class_name, klass)|
        result_ids = filtered_query_for(class_name).pluck(:resource_id)
        results_count = result_ids.count

        results = if filters[:resource_type].present? && filters[:resource_type] == class_name
                    paginate(klass.order_by_id_list(result_ids))
                  elsif filters[:resource_type].present?
                    ApplicationRecord.none
                  else
                    klass.order_by_id_list(result_ids.take(HIGHLIGHTED_RESULTS_COUNT))
                  end

        results_by_type.update(class_name => {
                                 count: results_count,
                                 results: results
                               })
      end
      broadcast(:ok, search_results)
    end
def call
      search_results = Decidim::Searchable.searchable_resources.inject({}) do |results_by_type, (class_name, klass)|
        result_ids = filtered_query_for(class_name).pluck(:resource_id)
        results_count = result_ids.count

        results = if filters[:resource_type].present? && filters[:resource_type] == class_name
                    paginate(klass.order_by_id_list(result_ids))
                  elsif filters[:resource_type].present?
                    ApplicationRecord.none
                  else
                    klass.order_by_id_list(result_ids.take(HIGHLIGHTED_RESULTS_COUNT))
                  end

        results_by_type.update(class_name => {
                                 count: results_count,
                                 results: results
                               })
      end
      broadcast(:ok, search_results)
    end
Public: Initializes the command.

 @param term: The term to search for.
 @param organization: The Organization to which the results are constrained.
 @param filters: (optional) A Hash of SearchableResource attributes to filter for.
 @param page_params: (optional) A Hash with `page` and `per_page` options to paginate.
 Executes the command. Broadcasts these events:

 - :ok when everything is valid, together with the search results.
 - :invalid if something failed and couldn't proceed.

 Returns nothing.