Select Git revision
CheckDir.hs
session.rb 1.15 KiB
class Session < ApplicationRecord
belongs_to :conference
belongs_to :stage
has_many :assignments
has_many :users, through: :assignments
has_many :candidates
has_many :session_speakers, dependent: :destroy
has_many :speakers, through: :session_speakers
scope :scheduled, -> { where(status: 'scheduled') }
scope :future, -> { where(starts_at: Time.now..) }
validates :ref_id, uniqueness: { scope: :conference_id }
after_update :notify_if_changed
self.implicit_order_column = :starts_at
def to_param
ref_id
end
def starts_at
super.in_time_zone(conference.time_zone)
end
def ends_at
super.in_time_zone(conference.time_zone)
end
def is_interpreted?
is_relevant?
end
def is_relevant?
RelevantStage.exists?(stage:)
end
def translators_needed?
is_interpreted? && assignments.length < 2
end
def backup_needed?
return false
end
def assignees?
assignments.length.positive?
end
private
def notify_if_changed
return if new_record?
if saved_changes.present?
ActiveSupport::Notifications.instrument("session.updated", record: self, changes: saved_changes)
end
end
end