From 0d4733b130cc010ede212c216281758a03e662c6 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Thu, 30 Jul 2020 02:20:10 -0700 Subject: [PATCH] Update users controller --- app/controllers/users_controller.rb | 2 +- app/models/event_schedule.rb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7cdcc80b..e69a52aa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -32,6 +32,6 @@ class UsersController < ApplicationController # Somewhat of a hack: users/current/edit 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 diff --git a/app/models/event_schedule.rb b/app/models/event_schedule.rb index bdbcd948..984dedc9 100644 --- a/app/models/event_schedule.rb +++ b/app/models/event_schedule.rb @@ -32,8 +32,10 @@ class EventSchedule < ApplicationRecord ## # True within 1 hour before and after the event. # - def happening_now?(threshold=1.hour) - false + 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)) end def self.withdrawn_or_canceled_event_schedules(schedule_ids)