Skip to content
Snippets Groups Projects
Select Git revision
  • ca04eb18c37b9d1a622745313ec4c349c128645b
  • main default protected
  • fix-search
  • network-typo-shielded-remmediation
  • rework-photopolicy-social-media
  • pr-47
  • isdn
7 results

faq.md

Blame
  • session.rb 1.13 KiB
    class Session < ApplicationRecord
      belongs_to :conference
      belongs_to :stage
      has_many :assignments
      has_many :users, through: :assignments
      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