Class: Decidim::Meetings::FilteredMeetings
- Inherits:
-
Query
- Object
- Query
- Decidim::Meetings::FilteredMeetings
- Defined in:
- app/queries/decidim/meetings/filtered_meetings.rb
Overview
A class used to find meetings filtered by components and a date range
Class Method Summary collapse
-
.for(components, start_at = nil, end_at = nil) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(components, start_at = nil, end_at = nil) ⇒ FilteredMeetings
constructor
Initializes the class.
-
#query ⇒ Object
Finds the Projects scoped to an array of components and filtered by a range of dates.
Constructor Details
#initialize(components, start_at = nil, end_at = nil) ⇒ FilteredMeetings
Initializes the class.
components - An array of Decidim::Component start_at - A date to filter resources created after it end_at - A date to filter resources created before it.
21 22 23 24 25 |
# File 'app/queries/decidim/meetings/filtered_meetings.rb', line 21 def initialize(components, start_at = nil, end_at = nil) @components = components @start_at = start_at @end_at = end_at end |
Class Method Details
.for(components, start_at = nil, end_at = nil) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
components - An array of Decidim::Component start_at - A date to filter resources created after it end_at - A date to filter resources created before it.
12 13 14 |
# File 'app/queries/decidim/meetings/filtered_meetings.rb', line 12 def self.for(components, start_at = nil, end_at = nil) new(components, start_at, end_at).query end |
Instance Method Details
#query ⇒ Object
Finds the Projects scoped to an array of components and filtered by a range of dates.
29 30 31 32 33 34 |
# File 'app/queries/decidim/meetings/filtered_meetings.rb', line 29 def query meetings = Decidim::Meetings::Meeting.not_hidden.published.where(component: @components) meetings = meetings.where("created_at >= ?", @start_at) if @start_at.present? meetings = meetings.where("created_at <= ?", @end_at) if @end_at.present? meetings end |