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 =
Recognised 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.
16 17 18 19 20 21 |
# File 'app/services/reviews_io_video_importer.rb', line 16 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.
14 15 16 |
# File 'app/services/reviews_io_video_importer.rb', line 14 def errors @errors end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
14 15 16 |
# File 'app/services/reviews_io_video_importer.rb', line 14 def force @force end |
#imported_count ⇒ Object (readonly)
Returns the value of attribute imported_count.
14 15 16 |
# File 'app/services/reviews_io_video_importer.rb', line 14 def imported_count @imported_count end |
#review ⇒ Object (readonly)
Returns the value of attribute review.
14 15 16 |
# File 'app/services/reviews_io_video_importer.rb', line 14 def review @review end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/reviews_io_video_importer.rb', line 23 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
36 37 38 |
# File 'app/services/reviews_io_video_importer.rb', line 36 def success? errors.empty? end |