Update users controller

This commit is contained in:
Michael Ball 2020-07-30 02:20:10 -07:00
parent e4c31633c5
commit 0d4733b130
2 changed files with 5 additions and 3 deletions

View file

@ -32,6 +32,6 @@ class UsersController < ApplicationController
# Somewhat of a hack: users/current/edit # Somewhat of a hack: users/current/edit
def load_user def load_user
@user ||= (params[:user_id] && params[:user_id] != 'current' && User.find(params[:user_id]) || current_user) @user ||= (params[:id] && params[:id] != 'current' && User.find(params[:id]) || current_user)
end end
end end

View file

@ -32,8 +32,10 @@ class EventSchedule < ApplicationRecord
## ##
# True within 1 hour before and after the event. # True within 1 hour before and after the event.
# #
def happening_now?(threshold=1.hour) def happening_now?(threshold=30.minutes)
false 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))
end end
def self.withdrawn_or_canceled_event_schedules(schedule_ids) def self.withdrawn_or_canceled_event_schedules(schedule_ids)