Files
old-holivud2/app/presenters/video_analysis_presenter.rb
2020-05-31 22:38:19 +02:00

57 lines
1.4 KiB
Ruby

class VideoAnalysisPresenter
def initialize(video, video_analysis, matches_presenter)
@video = video
@video_analysis = video_analysis
@matches_presenter = matches_presenter
end
def stale?
return if video.analysis_started_at.nil?
latest_release_created_at = [
video.appearance_releases.maximum(:created_at),
video.talent_releases.maximum(:created_at),
video.acquired_media_releases.maximum(:created_at)
].compact.max
latest_release_created_at > video.analysis_started_at
end
def bookmarks
video.bookmarks
end
def unreleased_appearances
video.unreleased_appearances
end
def video_url
return original_video_url if !video.analysis_success?
video_analysis.overlay_video_url || original_video_url
end
def chronological_appearances
@chronological_appearances ||= matches_presenter.build_chronological_matches
end
def chronological_graphics_matches
@chronological_graphics_matches ||= matches_presenter.build_graphics_matches
end
def chronological_audio_matches
@chronological_audio_matches ||= matches_presenter.build_chronological_audio_matches
end
def all_tracks_edl_events
@all_tracks_edl_events ||= matches_presenter.all_tracks_edl_events
end
private
attr_reader :video_analysis, :video, :matches_presenter
def original_video_url
ApplicationController._routes.url_helpers.rails_blob_url(video.file, host: AppHost.new.domain_with_port)
end
end