Class: VideoPosterExtractionWorker
- Inherits:
-
Object
- Object
- VideoPosterExtractionWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/video_poster_extraction_worker.rb
Overview
Sidekiq worker: video poster extraction.
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
-
#perform(video_id, timestamp_seconds = nil, redirect_to = nil, target_attribute = 'poster_image_id') ⇒ Object
target_attribute is a positional string so the JSON-serialized Sidekiq payload stays trivially serializable.
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(video_id, timestamp_seconds = nil, redirect_to = nil, target_attribute = 'poster_image_id') ⇒ Object
target_attribute is a positional string so the JSON-serialized Sidekiq
payload stays trivially serializable. Defaults preserve the original
poster_image_id flow for callers that don't pass it.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/workers/video_poster_extraction_worker.rb', line 13 def perform(video_id, = nil, redirect_to = nil, target_attribute = 'poster_image_id') video = Video.find(video_id) = 5.0 if .nil? || < 0 total(100) at(0, "Starting frame extraction for video #{video.title}") store redirect_to: redirect_to if redirect_to.present? at(25, 'Extracting frame using optimized service...') service = VideoPosterExtractionService.new(video, , target_attribute: target_attribute.to_sym) service.extract_poster at(100, 'Frame extraction completed successfully!') rescue VideoPosterExtractionService::ExtractionError => e store error_message: e. raise end |