| Module | UpcomingEvents::DisciplineExtensions |
| In: |
app/models/upcoming_events/discipline_extensions.rb
|
| upcoming_events | [RW] | |
| upcoming_weekly_series | [RW] |
# File app/models/upcoming_events/discipline_extensions.rb, line 6
6: def find_all_upcoming_events(dates)
7: single_day_events = SingleDayEvent.find(
8: :all,
9: :conditions => scope_by_sanctioned(['date between ? and ? and cancelled = false and parent_id is null and discipline in (?)', dates.begin, dates.end, self.names]),
10: :order => 'date')
11:
12: # Find MultiDayEvents, not their children, nor MultiDayEvents subclasses
13: multi_day_events = MultiDayEvent.find(
14: :all,
15: :select => "distinct events.id, events.name, events.date, events.discipline, events.flyer, events.flyer_approved, events.beginner_friendly, events.bar_points, events.website, events.registration_link",
16: :joins => "left outer join events as childrens_events on childrens_events.parent_id = events.id",
17: :conditions => scope_by_sanctioned([%Q{ childrens_events.date between ? and ? and
18: (childrens_events.type is null or childrens_events.type = 'SingleDayEvent') and
19: events.cancelled = false and
20: events.practice = false and
21: events.instructional = false and
22: events.discipline in (?) and
23: events.type = ? },
24: dates.begin, dates.end, self.names, "MultiDayEvent"]),
25: :order => 'events.date')
26:
27: # Find Series events, but not their parents, nor WeeklySeries
28: series_events = SingleDayEvent.find(
29: :all,
30: :select => "distinct events.id, events.name, events.date, events.discipline, events.flyer, events.flyer_approved, events.beginner_friendly, events.bar_points, events.website, events.registration_link",
31: :include => :parent,
32: :conditions => scope_by_sanctioned(
33: [%Q{ events.date between ? and ?
34: and events.cancelled = false
35: and events.instructional = false
36: and events.practice = false
37: and events.parent_id is not null
38: and parents_events.type = ?
39: and parents_events.discipline in (?) },
40: dates.begin, dates.end, "Series", self.names]),
41: :order => 'events.date')
42:
43: single_day_events + multi_day_events + series_events
44: end
# File app/models/upcoming_events/discipline_extensions.rb, line 46
46: def find_all_upcoming_weekly_series(dates)
47: WeeklySeries.find(
48: :all,
49: :select => "distinct events.id, events.name, events.date, events.discipline, events.flyer, events.flyer_approved, events.beginner_friendly, events.bar_points, events.website, events.registration_link",
50: :joins => "left outer join events as childrens_events on childrens_events.parent_id = events.id",
51: :conditions => scope_by_sanctioned([%Q{ childrens_events.date between ? and ? and
52: (childrens_events.type is null or childrens_events.type = 'SingleDayEvent') and
53: events.cancelled = false and
54: events.practice = false and
55: events.instructional = false and
56: events.discipline in (?)},
57: dates.begin, dates.end, self.names]),
58: :order => 'events.date')
59: end