[fix] Fix time displayed in happening_now.haml; Make event_schedule#happening_now? more efficient
This commit is contained in:
parent
2628952142
commit
85fe894876
2 changed files with 6 additions and 7 deletions
|
|
@ -55,9 +55,10 @@ class EventSchedule < ApplicationRecord
|
|||
# True within `threshold` before and after the event.
|
||||
#
|
||||
def happening_now?(threshold = 30.minutes)
|
||||
return false if end_time < Time.now
|
||||
event_time_range = start_time..end_time
|
||||
now_range = (Time.now - threshold)..(Time.now + threshold)
|
||||
event_time_range.overlaps?(now_range) && (end_time > Time.now)
|
||||
event_time_range.overlaps?(now_range)
|
||||
end
|
||||
|
||||
def self.withdrawn_or_canceled_event_schedules(schedule_ids)
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@
|
|||
.col-md-12
|
||||
%h2
|
||||
#{pluralize(@events_schedules.count, 'Event')} Occurring Within The Next 30 minutes.
|
||||
%br
|
||||
%small
|
||||
This page was loaded at
|
||||
= inyourtz(Time.now) do
|
||||
= Time.now.strftime('%a %b %d at %I:%M %P (%z)')
|
||||
\.
|
||||
%h3
|
||||
This page was loaded at
|
||||
= inyourtz(Time.now) do
|
||||
#{Time.now.strftime('%a %b %d at %I:%M %P (%z)').to_s}
|
||||
|
||||
.row
|
||||
/ TODO: Clean this up, merge with all events page.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue