module Recordings
  class PurgeExpiredJob
    include Sidekiq::Job
    sidekiq_options retry: 1, queue: "default"

    def perform
      Recording.expired_pending_purge.find_each do |recording|
        Recordings::Delete.new(recording, reason: :expired).call
      rescue StandardError => e
        Rails.logger.warn("[Recordings::PurgeExpiredJob] #{recording.id}: #{e.message}")
      end
    end
  end
end
