Files
MatchLiveTv/backend/app/models/recording.rb
Emiliano Frascaro bba6df52c0 Initial commit: monorepo Match Live TV.
Rails API, app Flutter, infrastruttura Docker/MediaMTX, sito marketing e documentazione di deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 17:45:37 +02:00

22 lines
589 B
Ruby

class Recording < ApplicationRecord
STATUSES = %w[processing ready expired].freeze
belongs_to :stream_session
belongs_to :team
validates :status, inclusion: { in: STATUSES }
scope :ready, -> { where(status: "ready").where("expires_at IS NULL OR expires_at > ?", Time.current) }
scope :for_team, ->(team) { where(team: team) }
def replay_url
return nil unless ready? && stream_session_id.present?
"#{MatchLiveTv.app_public_url.chomp('/')}/replay/#{stream_session_id}"
end
def ready?
status == "ready" && (expires_at.nil? || expires_at.future?)
end
end