Class: Decidim::Results::ResultSearch

Inherits:
ResourceSearch
  • Object
show all
Defined in:
app/services/decidim/results/result_search.rb

Overview

This class handles search and filtering of results. Needs a ‘current_feature` param with a `Decidim::Feature` in order to find the results.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ResultSearch

Public: Initializes the service. feature - A Decidim::Feature to get the results from. page - The page number to paginate the results. per_page - The number of proposals to return per page.



13
14
15
# File 'app/services/decidim/results/result_search.rb', line 13

def initialize(options = {})
  super(Result.all, options)
end

Instance Method Details

#search_search_textObject

Handle the search_text filter



18
19
20
21
22
# File 'app/services/decidim/results/result_search.rb', line 18

def search_search_text
  query
    .where(localized_search_text_in(:title), text: "%#{search_text}%")
    .or(query.where(localized_search_text_in(:description), text: "%#{search_text}%"))
end