class Decidim::Meetings::FilteredMeetings
A class used to find meetings filtered by components and a date range
def self.for(components, start_at = nil, end_at = nil)
start_at - A date to filter resources created after it
components - An array of Decidim::Component
Syntactic sugar to initialize the class and return the queried objects.
def self.for(components, start_at = nil, end_at = nil) new(components, start_at, end_at).query end
def initialize(components, start_at = nil, end_at = nil)
start_at - A date to filter resources created after it
components - An array of Decidim::Component
Initializes the class.
def initialize(components, start_at = nil, end_at = nil) @components = components @start_at = start_at @end_at = end_at end
def query
Finds the Projects scoped to an array of components and filtered
def query meetings = Decidim::Meetings::Meeting.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