Class: Decidim::Sortitions::SortitionSearch

Inherits:
ResourceSearch
  • Object
show all
Defined in:
decidim-sortitions/app/services/decidim/sortitions/sortition_search.rb

Overview

A service to encapsualte all the logic when searching and filtering sortitions in a participatory process.

Instance Attribute Summary

Attributes inherited from ResourceSearch

#component, #organization, #user

Instance Method Summary collapse

Methods inherited from ResourceSearch

#base_query, #results, #search_category_id, #search_origin, #search_scope_id, #search_search_text, text_search_fields

Constructor Details

#initialize(options = {}) ⇒ SortitionSearch

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


13
14
15
# File 'decidim-sortitions/app/services/decidim/sortitions/sortition_search.rb', line 13

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

Instance Method Details

#search_stateObject

Handle the state filter


18
19
20
21
22
23
24
25
26
27
# File 'decidim-sortitions/app/services/decidim/sortitions/sortition_search.rb', line 18

def search_state
  case state
  when "active"
    query.active
  when "cancelled"
    query.cancelled
  else # Assume 'all'
    query
  end
end