Class: FestivityEventList
- Inherits:
-
Object
- Object
- FestivityEventList
show all
- Defined in:
- app/models/festivity_event_list.rb
Defined Under Namespace
Classes: FestivityEvent, FestivityEventPerformance, FestivityLocation
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
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
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
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/models/festivity_event_list.rb', line 30
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
|
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/models/festivity_event_list.rb', line 42
def self.find_related_events(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
24
25
26
27
28
|
# File 'app/models/festivity_event_list.rb', line 11
def self.search(criteria, order_by)
begin
where_clause = parse_criteria(criteria)
rescue ActiveRecord::RecordNotFound
return FestivityEventList.new([])
end
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
|