Sha256: d33c701b13cf4ba07f753dfb718709c46d8affcc84186b78e0228f6f39aa48c1

Contents?: true

Size: 747 Bytes

Versions: 23

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    # This query class filters participatory processes given a filter name.
    # It uses the start and end dates to select the correct processes.
    class FilteredParticipatoryProcesses < Rectify::Query
      def initialize(filter = "active")
        @filter = filter
      end

      def query
        processes = Decidim::ParticipatoryProcess.all

        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
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
decidim-participatory_processes-0.7.4 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.7.3 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.7.2 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.7.1 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.7.0 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.8 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-0.6.8 decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.7 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-0.6.7 decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.6 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-0.6.6 decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.5 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-0.6.5 decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.4 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-0.6.4 decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.3 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-0.6.3 decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.2 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-0.6.2 decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb
decidim-participatory_processes-0.6.1 app/queries/decidim/participatory_processes/filtered_participatory_processes.rb