backup_worker.rb 353 B

1234567891011121314151617
  1. # frozen_string_literal: true
  2. class BackupWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'pull'
  5. def perform(backup_id)
  6. backup = Backup.find(backup_id)
  7. user = backup.user
  8. BackupService.new.call(backup)
  9. user.backups.where.not(id: backup.id).destroy_all
  10. UserMailer.backup_ready(user, backup).deliver_later
  11. end
  12. end