Class: Decidim::Debates::DebateSearch
- Inherits:
-
ResourceSearch
- Object
- ResourceSearch
- Decidim::Debates::DebateSearch
- Defined in:
- app/services/decidim/debates/debate_search.rb
Overview
This class handles search and filtering of debates. Needs a ‘current_component` param with a `Decidim::Component` in order to find the debates.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DebateSearch
constructor
Public: Initializes the service.
-
#search_activity ⇒ Object
Handle the activity filter.
-
#search_state ⇒ Object
Handle the state filter.
Constructor Details
#initialize(options = {}) ⇒ DebateSearch
Public: Initializes the service. component - A Decidim::Component to get the debates from. page - The page number to paginate the results. per_page - The number of debates to return per page.
15 16 17 |
# File 'app/services/decidim/debates/debate_search.rb', line 15 def initialize( = {}) super(Debate.not_hidden, ) end |
Instance Method Details
#search_activity ⇒ Object
Handle the activity filter
20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/decidim/debates/debate_search.rb', line 20 def search_activity case activity when "commented" query.commented_by(user) when "my_debates" query.(user) else # Assume 'all' query end end |
#search_state ⇒ Object
Handle the state filter
32 33 34 |
# File 'app/services/decidim/debates/debate_search.rb', line 32 def search_state apply_scopes(%w(open closed), state) end |