thread_resolve_worker.rb 514 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. class ThreadResolveWorker
  3. include Sidekiq::Worker
  4. include ExponentialBackoff
  5. sidekiq_options queue: 'pull', retry: 3
  6. def perform(child_status_id, parent_url, options = {})
  7. child_status = Status.find(child_status_id)
  8. parent_status = FetchRemoteStatusService.new.call(parent_url, **options.deep_symbolize_keys)
  9. return if parent_status.nil?
  10. child_status.thread = parent_status
  11. child_status.save!
  12. rescue ActiveRecord::RecordNotFound
  13. true
  14. end
  15. end