Class: ReviewsIoVideoImporter
- Inherits:
-
Object
- Object
- ReviewsIoVideoImporter
- Defined in:
- app/services/reviews_io_video_importer.rb
Overview
Imports review videos from Reviews.io into the Video library via Cloudflare Stream.
Creates Video records with category 'ugc' (invisible on the public site),
tags them, and links them back to the ReviewsIo record.
Usage:
ReviewsIoVideoImporter.new(review).call
ReviewsIoVideoImporter.new(review, force: true).call # re-import all
Constant Summary collapse
- BASE_TAGS =
%w[review-video reviews-io ugc user-generated-content].freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#imported_count ⇒ Object
readonly
Returns the value of attribute imported_count.
-
#review ⇒ Object
readonly
Returns the value of attribute review.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(review, force: false) ⇒ ReviewsIoVideoImporter
constructor
A new instance of ReviewsIoVideoImporter.
- #success? ⇒ Boolean
Constructor Details
#initialize(review, force: false) ⇒ ReviewsIoVideoImporter
Returns a new instance of ReviewsIoVideoImporter.
15 16 17 18 19 20 |
# File 'app/services/reviews_io_video_importer.rb', line 15 def initialize(review, force: false) @review = review @force = force @imported_count = 0 @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'app/services/reviews_io_video_importer.rb', line 13 def errors @errors end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
13 14 15 |
# File 'app/services/reviews_io_video_importer.rb', line 13 def force @force end |
#imported_count ⇒ Object (readonly)
Returns the value of attribute imported_count.
13 14 15 |
# File 'app/services/reviews_io_video_importer.rb', line 13 def imported_count @imported_count end |
#review ⇒ Object (readonly)
Returns the value of attribute review.
13 14 15 |
# File 'app/services/reviews_io_video_importer.rb', line 13 def review @review end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/reviews_io_video_importer.rb', line 22 def call return self unless review.has_videos? review.video_urls.each_with_index do |url, index| import_single_video(url, index) rescue StandardError => e @errors << "Video #{index} (#{url.truncate(80)}): #{e.}" Rails.logger.error "[ReviewsIoVideoImporter] Review #{review.id}, video #{index}: #{e.}" end self end |
#success? ⇒ Boolean
35 36 37 |
# File 'app/services/reviews_io_video_importer.rb', line 35 def success? errors.empty? end |