Sha256: 9cf9c375cfed57f38be19b6bccfc1c10f3b5277829144cbff709857124ad7ba7

Contents?: true

Size: 941 Bytes

Versions: 19

Compression:

Stored size: 941 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 < Decidim::Query
      def initialize(filter = "active")
        @filter = filter
      end

      def query
        processes = Decidim::ParticipatoryProcess.all

        processes = case @filter
                    when "past"
                      processes.past
                    when "upcoming"
                      processes.upcoming
                    when "active"
                      processes.active
                    else
                      processes
                    end

        Decidim::ParticipatoryProcessGroup.where(id: processes.pluck(:decidim_participatory_process_group_id))
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.29.1 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.28.4 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.27.9 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.29.0 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.28.3 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.27.8 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.29.0.rc4 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.29.0.rc3 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.29.0.rc2 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.29.0.rc1 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.28.2 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.27.7 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.28.1 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.27.6 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.28.0 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.27.5 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.28.0.rc5 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.28.0.rc4 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb
decidim-participatory_processes-0.27.4 app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb