26 lines
640 B
Ruby
26 lines
640 B
Ruby
class VideoReleaseConfirmation < ApplicationRecord
|
|
belongs_to :video
|
|
belongs_to :releasable, polymorphic: true
|
|
belongs_to :file_info, optional: true
|
|
|
|
scope :order_by_ranked_release_type, -> { order(ReleaseRankOrder.new.sql) }
|
|
|
|
def appears_at
|
|
Timecode.from_seconds(time_elapsed.to_f).to_s
|
|
end
|
|
|
|
def file
|
|
ActiveStorage::Attachment.find(file_id)
|
|
end
|
|
|
|
private
|
|
|
|
class ReleaseRankOrder
|
|
def sql
|
|
attribute = "releasable_type"
|
|
types = [TalentRelease, AppearanceRelease, LocationRelease, AcquiredMediaRelease, MaterialRelease, MusicRelease]
|
|
CustomRankOrder.new(attribute, types).sql
|
|
end
|
|
end
|
|
end
|