Class: Decidim::Meetings::MeetingSearch

Inherits:
ResourceSearch
  • Object
show all
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

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.



15
16
17
18
# File 'app/services/decidim/meetings/meeting_search.rb', line 15

def initialize(options = {})
  scope = options.fetch(:scope, Meeting.all)
  super(scope, options)
end

Instance Method Details

#search_dateObject

Handle the date filter



21
22
23
# File 'app/services/decidim/meetings/meeting_search.rb', line 21

def search_date
  apply_scopes(%w(upcoming past), date)
end

#search_spaceObject



25
26
27
28
29
# File 'app/services/decidim/meetings/meeting_search.rb', line 25

def search_space
  return query if options[:space].blank? || options[:space] == "all"

  query.joins(:component).where(decidim_components: { participatory_space_type: options[:space].classify })
end