Class: Decidim::Meetings::MeetingSearch
- Inherits:
-
ResourceSearch
- Object
- Searchlight::Search
- ResourceSearch
- Decidim::Meetings::MeetingSearch
- Defined in:
- decidim-meetings/app/services/decidim/meetings/meeting_search.rb
Overview
This class handles search and filtering of meetings. Needs a ‘current_feature` param with a `Decidim::Feature` 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.
Methods inherited from ResourceSearch
#base_query, #search_category_id, #search_scope_id
Constructor Details
#initialize(options = {}) ⇒ MeetingSearch
Public: Initializes the service. feature - A Decidim::Feature 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 |
# File 'decidim-meetings/app/services/decidim/meetings/meeting_search.rb', line 13 def initialize( = {}) super(Meeting.all, ) end |
Instance Method Details
#search_date ⇒ Object
Handle the date filter
25 26 27 28 29 30 31 |
# File 'decidim-meetings/app/services/decidim/meetings/meeting_search.rb', line 25 def search_date if [:date] == "upcoming" query.where("start_time >= ? ", Time.current).order(start_time: :asc) elsif [:date] == "past" query.where("start_time <= ? ", Time.current).order(start_time: :desc) end end |
#search_search_text ⇒ Object
Handle the search_text filter
18 19 20 21 22 |
# File 'decidim-meetings/app/services/decidim/meetings/meeting_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 |