Sha256: c43d3587f362cb521061be9a4b10de76dd2d0dd62fc28ded3e3adced163e7e6b
Contents?: true
Size: 1.29 KB
Versions: 51
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Decidim module Consultations # Service that encapsulates all logic related to filtering consultations. class ConsultationSearch < Searchlight::Search # Public: Initializes the service. # page - The page number to paginate the results. # per_page - The number of proposals to return per page. def initialize(options = {}) super(options) end def base_query Decidim::Consultation.where(organization: options[:organization]).published end # Handle the search_text filter def search_search_text query .where("title->>'#{current_locale}' ILIKE ?", "%#{search_text}%") .or( query.where("description->>'#{current_locale}' ILIKE ?", "%#{search_text}%") ) .or( query.where("subtitle->>'#{current_locale}' ILIKE ?", "%#{search_text}%") ) end # Handle the state filter def search_state case state when "active" query.active when "upcoming" query.upcoming when "finished" query.finished else # Assume all query end end private def current_locale I18n.locale.to_s end end end end
Version data entries
51 entries across 51 versions & 1 rubygems