Sha256: b4de7d5ecb41b65f1a1833dacd6179c06944f9efe61b04f56e48b7261daa7e89
Contents?: true
Size: 993 Bytes
Versions: 44
Compression:
Stored size: 993 Bytes
Contents
# frozen_string_literal: true module Decidim module ParticipatoryProcesses # This query class filters participatory processes groups given a filter name. # The filter is applied checking the start and end dates of the processes in # the group. class FilteredParticipatoryProcessGroups < Rectify::Query def initialize(filter = "active") @filter = filter end def query processes = Decidim::ParticipatoryProcess.all processes = case @filter when "past" processes.where("decidim_participatory_processes.end_date <= ?", Time.current) when "upcoming" processes.where("decidim_participatory_processes.start_date > ?", Time.current) else processes end Decidim::ParticipatoryProcessGroup.where(id: processes.pluck(:decidim_participatory_process_group_id)) end end end end
Version data entries
44 entries across 44 versions & 2 rubygems