Class: Decidim::Initiatives::OutdatedValidatingInitiatives

Inherits:
Query
  • Object
show all
Defined in:
decidim-initiatives/app/queries/decidim/initiatives/outdated_validating_initiatives.rb

Overview

Class uses to retrieve initiatives that have been a long time in validating state

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Query

#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|

Constructor Details

#initialize(period_length) ⇒ OutdatedValidatingInitiatives

Initializes the class.

period_length - Maximum time in validating state



18
19
20
# File 'decidim-initiatives/app/queries/decidim/initiatives/outdated_validating_initiatives.rb', line 18

def initialize(period_length)
  @period_length = Time.current - period_length
end

Class Method Details

.for(period_length) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.

period_length - Maximum time in validating state



11
12
13
# File 'decidim-initiatives/app/queries/decidim/initiatives/outdated_validating_initiatives.rb', line 11

def self.for(period_length)
  new(period_length).query
end

Instance Method Details

#queryObject

Retrieves the available initiative types for the given organization.



23
24
25
26
27
# File 'decidim-initiatives/app/queries/decidim/initiatives/outdated_validating_initiatives.rb', line 23

def query
  Decidim::Initiative
    .where(state: "validating")
    .where(updated_at: ...@period_length)
end