Add a Happening Now View
This commit is contained in:
parent
0d4733b130
commit
70bde86dd6
8 changed files with 80 additions and 9 deletions
|
|
@ -27,15 +27,21 @@ class EventSchedule < ApplicationRecord
|
|||
|
||||
delegate :guid, to: :room, prefix: true
|
||||
|
||||
delegate :timezone, to: :event
|
||||
def timezone
|
||||
event.conference.timezone
|
||||
end
|
||||
|
||||
##
|
||||
# True within 1 hour before and after the event.
|
||||
# True within `threshold` before and after the event.
|
||||
#
|
||||
def happening_now?(threshold=30.minutes)
|
||||
pre_start_time = (start_time - threshold).in_time_zone(timezone)
|
||||
end_time_with_threshold = (end_time + threshold).in_time_zone(timezone)
|
||||
(pre_start_time..end_time_with_threshold).cover?(Time.now.in_time_zone(timezone))
|
||||
in_tz_start = start_time.in_time_zone(timezone)
|
||||
in_tz_end = start_time.in_time_zone(timezone)
|
||||
in_tz_start -= in_tz_start.utc_offset
|
||||
in_tz_end -= in_tz_end.utc_offset
|
||||
begin_range = Time.now - threshold
|
||||
end_range = Time.now + threshold + 1.minute # The range is exclusive.
|
||||
(begin_range..end_range).cover?(in_tz_start) || (begin_range..end_range).cover?(in_tz_end)
|
||||
end
|
||||
|
||||
def self.withdrawn_or_canceled_event_schedules(schedule_ids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue