From 51f9ba0206194bcd64cf24795f8de05a228c1046 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Fri, 12 Mar 2021 09:51:24 -0800 Subject: [PATCH] happening now - model implementation --- app/models/conference.rb | 10 ++++++++++ app/models/event.rb | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index e9a0fa23..581f4839 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -784,6 +784,16 @@ class Conference < ApplicationRecord end_date < Time.current end + def find_live_events() + live_events = [] + for event in program.events + if event.is_live? + live_events.append(event) + end + end + live_events + end + private # Returns a different html colour for every i and consecutive colors are diff --git a/app/models/event.rb b/app/models/event.rb index d10ae1a1..238a6871 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -7,7 +7,6 @@ # id :bigint not null, primary key # abstract :text # comments_count :integer default(0), not null -# committee_review :text # description :text # guid :string not null # is_highlight :boolean default(FALSE) @@ -338,6 +337,10 @@ class Event < ApplicationRecord time <=> other.time end + def is_live? + start_time >= Time.now && Time.now <= start_time + event_type.length + end + private ##