Class: Decidim::Meetings::MeetingSearch
- Inherits:
-
ResourceSearch
- Object
- ResourceSearch
- Decidim::Meetings::MeetingSearch
- Defined in:
- app/services/decidim/meetings/meeting_search.rb
Overview
This class handles search and filtering of meetings. Needs a ‘current_component` param with a `Decidim::Component` in order to find the meetings.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MeetingSearch
constructor
Public: Initializes the service.
-
#search_date ⇒ Object
Handle the date filter.
-
#search_search_text ⇒ Object
Handle the search_text filter.
- #search_space ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MeetingSearch
Public: Initializes the service. component - A Decidim::Component to get the meetings from. page - The page number to paginate the results. per_page - The number of proposals to return per page.
13 14 15 16 |
# File 'app/services/decidim/meetings/meeting_search.rb', line 13 def initialize( = {}) scope = .fetch(:scope, Meeting.all) super(scope, ) end |
Instance Method Details
#search_date ⇒ Object
Handle the date filter
26 27 28 29 30 31 32 |
# File 'app/services/decidim/meetings/meeting_search.rb', line 26 def search_date if [:date] == "upcoming" query.where("end_time >= ? ", Time.current).order(start_time: :asc) elsif [:date] == "past" query.where("end_time <= ? ", Time.current).order(start_time: :desc) end end |
#search_search_text ⇒ Object
Handle the search_text filter
19 20 21 22 23 |
# File 'app/services/decidim/meetings/meeting_search.rb', line 19 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 |
#search_space ⇒ Object
34 35 36 37 38 |
# File 'app/services/decidim/meetings/meeting_search.rb', line 34 def search_space return query if [:space].blank? || [:space] == "all" query.joins(:component).where(decidim_components: { participatory_space_type: [:space].classify }) end |