[fix] live_events return json; use the provided happening_now? function
This commit is contained in:
parent
25af736868
commit
7fe1c597ff
3 changed files with 2 additions and 12 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue