Class: FestivityEventList
- Inherits:
-
Object
- Object
- FestivityEventList
- Defined in:
- app/models/festivity_event_list.rb
Defined Under Namespace
Classes: FestivityEvent, FestivityEventPerformance, FestivityLocation
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Class Method Summary collapse
- .find_by_location(location_id) ⇒ Object
- .find_related_events(criteria) ⇒ Object
- .search(criteria, order_by) ⇒ Object
Instance Method Summary collapse
-
#initialize(event_performances) ⇒ FestivityEventList
constructor
A new instance of FestivityEventList.
Constructor Details
#initialize(event_performances) ⇒ FestivityEventList
Returns a new instance of FestivityEventList.
5 6 7 8 9 |
# File 'app/models/festivity_event_list.rb', line 5 def initialize(event_performances) @events = event_performances.group_by {|perf| perf.event_id }. map { |perfs| FestivityEventList::FestivityEvent.new(perfs[0], perfs[1]) } end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
3 4 5 |
# File 'app/models/festivity_event_list.rb', line 3 def events @events end |
Class Method Details
.find_by_location(location_id) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/festivity_event_list.rb', line 25 def self.find_by_location(location_id) FestivityEventList.new( FestivityEventList::FestivityEventPerformance. includes(:assets). joins(:festivity_categories). where(location_id: location_id). group("performance_id"). order("featured_item DESC, start_date ASC"). preload(:festivity_categories) ) end |
.find_related_events(criteria) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/festivity_event_list.rb', line 37 def self.(criteria) where_clause = parse_criteria(criteria) FestivityEventList.new( FestivityEventList::FestivityEventPerformance. includes(:assets). joins(:festivity_categories). where(where_clause). where("event_id != ?", criteria[:event_id]). group("performance_id"). order("featured_item DESC, start_date ASC"). preload(:festivity_categories) ) end |
.search(criteria, order_by) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/festivity_event_list.rb', line 11 def self.search(criteria, order_by) where_clause = parse_criteria(criteria) # where in event ids FestivityEventList.new( FestivityEventList::FestivityEventPerformance. includes(:assets). joins(:festivity_categories). where(where_clause). group("performance_id"). order("featured_item DESC, #{order_by} ASC"). preload(:festivity_categories) ) end |