Class: Decidim::Initiatives::OutdatedValidatingInitiatives
- Inherits:
-
Query
- Object
- Query
- Decidim::Initiatives::OutdatedValidatingInitiatives
- Defined in:
- 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
-
.for(period_length) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(period_length) ⇒ OutdatedValidatingInitiatives
constructor
Initializes the class.
-
#query ⇒ Object
Retrieves the available initiative types for the given organization.
Constructor Details
#initialize(period_length) ⇒ OutdatedValidatingInitiatives
Initializes the class.
period_length - Maximum time in validating state
18 19 20 |
# File '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 'app/queries/decidim/initiatives/outdated_validating_initiatives.rb', line 11 def self.for(period_length) new(period_length).query end |
Instance Method Details
#query ⇒ Object
Retrieves the available initiative types for the given organization.
23 24 25 26 27 |
# File 'app/queries/decidim/initiatives/outdated_validating_initiatives.rb', line 23 def query Decidim::Initiative .where(state: "validating") .where("updated_at < ?", @period_length) end |