class Decidim::Meetings::MeetingSearch
find the meetings.
‘current_feature` param with a `Decidim::Feature` in order to
This class handles search and filtering of meetings. Needs a
def initialize(options = {})
page - The page number to paginate the results.
feature - A Decidim::Feature to get the meetings from.
Public: Initializes the service.
def initialize(options = {}) super(Meeting.all, options) end
def localized_search_text_in(field)
Resource.where(localized_search_text_for(:title, text: "my_query"))
Example:
available locales. Note that it is intended to be used as follows:
Internal: builds the needed query to search for a text in the organization's
def localized_search_text_in(field) options[:organization].available_locales.map { |l| "#{field} ->> '#{l}' ILIKE :text" }.join(" OR ") end
def search_date
def search_date if options[:date] == "upcoming" query.where("start_time >= ? ", Time.current).order(start_time: :asc) elsif options[:date] == "past" query.where("start_time <= ? ", Time.current).order(start_time: :desc) end end
def search_search_text
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