created current scope in event_schedule model and conference info link name and path changed

This commit is contained in:
AnithaPal 2016-08-23 10:23:26 -04:00
parent e8d3177ec1
commit e82a3e1727
17 changed files with 53 additions and 65 deletions

View file

@ -41,7 +41,6 @@ class Event < ActiveRecord::Base
scope :canceled, -> { where(state: 'canceled') }
scope :withdrawn, -> { where(state: 'withdrawn') }
scope :highlighted, -> { where(is_highlight: true) }
scope :current, -> { joins(:event_type).where('start_time <= ? AND state = ?', Time.current, 'confirmed').map { |e| e if e.end_time > Time.current }.compact }
state_machine initial: :new do
state :new
@ -248,13 +247,6 @@ class Event < ActiveRecord::Base
event_schedules.find_by(schedule_id: program.selected_schedule_id).try(:start_time)
end
##
# Returns end of the event
#
def end_time
self.start_time + self.event_type.length.minutes
end
private
##
@ -302,11 +294,4 @@ class Event < ActiveRecord::Base
def conference_id
program.conference_id
end
##
# Compares event start_time, end_with with current time to predict current events
#
def current?
Time.current >= self.start_time && Time.current <= self.end_time
end
end

View file

@ -12,6 +12,7 @@ class EventSchedule < ActiveRecord::Base
scope :confirmed, -> { joins(:event).where('state = ?', 'confirmed') }
scope :canceled, -> { joins(:event).where('state = ?', 'canceled') }
scope :withdrawn, -> { joins(:event).where('state = ?', 'withdrawn') }
scope :current, -> { where('start_time <= ?', Time.current).select{ |es| es.end_time >= Time.current }}
delegate :guid, to: :room, prefix: true