Class: Decidim::ParticipatoryProcesses::FilteredParticipatoryProcesses

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb

Overview

This query class filters participatory processes given a filter name. It uses the start and end dates to select the correct processes.

Instance Method Summary collapse

Constructor Details

#initialize(filter = "active") ⇒ FilteredParticipatoryProcesses

Returns a new instance of FilteredParticipatoryProcesses.


8
9
10
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb', line 8

def initialize(filter = "active")
  @filter = filter
end

Instance Method Details

#queryObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb', line 12

def query
  processes = Decidim::ParticipatoryProcess.all

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