Skip to content
Snippets Groups Projects
Select Git revision
  • b1dcbc9edd964b9d0cab6c26db4d502840011ac4
  • main default protected
  • 75389691-a67c-422a-91e9-aa58bfb5-main-patch-32205
  • test-pipe
  • extended-scripts
  • structured-badges
  • guix-pipeline
  • cabal-pipeline
8 results

CheckDir.hs

Blame
  • 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