Class: OembedContentRefreshWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/oembed_content_refresh_worker.rb

Overview

Weekly worker to refresh oEmbed content in blog posts

This keeps embedded content (FAQs, videos, images) current:

  • Updates FAQ content and JSON-LD schema when FAQs change
  • Updates video thumbnails and metadata
  • Updates image transformations

Scheduled weekly via sidekiq-scheduler

Instance Method Summary collapse

Instance Method Details

#performObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/workers/oembed_content_refresh_worker.rb', line 17

def perform
  Rails.logger.info '[OembedContentRefresh] Starting weekly oEmbed content refresh'

  service = Oembed::ContentRefreshService.new
  result = service.refresh_all

  Rails.logger.info "[OembedContentRefresh] Completed: #{result[:posts_updated]} posts updated, " \
                    "#{result[:faqs_refreshed]} FAQs, #{result[:products_refreshed]} products, " \
                    "#{result[:videos_refreshed]} videos, #{result[:images_refreshed]} images, " \
                    "#{result[:errors].count} errors"

  # Report errors if any
  if result[:errors].any?
    result[:errors].first(10).each do |error|
      Rails.logger.warn "[OembedContentRefresh] Error: #{error}"
    end
  end

  result
end