[fix] live_events return json; use the provided happening_now? function

This commit is contained in:
Jimmy 2021-03-17 07:34:42 +08:00 committed by CactusPuppy
parent 25af736868
commit 7fe1c597ff
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82
3 changed files with 2 additions and 12 deletions

View file

@ -114,7 +114,7 @@ class ConferencesController < ApplicationController
def live_events def live_events
conference = Conference.find_by(short_title: params[:conference_id]) conference = Conference.find_by(short_title: params[:conference_id])
conference.find_live_events.to_json render json: conference.find_live_events.to_json
end end
private private

View file

@ -785,13 +785,7 @@ class Conference < ApplicationRecord
end end
def find_live_events def find_live_events
live_events = [] program.events.select(&:happening_now?)
program.events.each do |event|
if event.live?
live_events.append(event)
end
end
live_events
end end
private private

View file

@ -337,10 +337,6 @@ class Event < ApplicationRecord
time <=> other.time time <=> other.time
end end
def is_live?
time >= Time.now && Time.now <= time + event_type.length
end
private private
## ##