Sha256: eae49de21f6ddd3c0678ddc2e7b341a66813db76b006fcb8d95ae03b4065b6b8
Contents?: true
Size: 1.26 KB
Versions: 30
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Decidim module Sortitions # A service to encapsualte all the logic when searching and filtering # sortitions in a participatory process. class SortitionSearch < ResourceSearch # Public: Initializes the service. # component - A Decidim::Component to get the proposals from. # page - The page number to paginate the results. # per_page - The number of proposals to return per page. def initialize(options = {}) super(Sortition.all, options) end # Handle the search_text filter def search_search_text query .where("title->>'#{current_locale}' ILIKE ?", "%#{search_text}%") .or( query.where("additional_info->>'#{current_locale}' ILIKE ?", "%#{search_text}%") ) .or( query.where("witnesses->>'#{current_locale}' ILIKE ?", "%#{search_text}%") ) end # Handle the state filter def search_state case state when "active" query.active when "cancelled" query.cancelled else # Assume 'all' query end end private def current_locale I18n.locale.to_s end end end end
Version data entries
30 entries across 30 versions & 1 rubygems