about summary refs log tree commit diff
path: root/app/workers/backup_worker.rb
blob: ec6db4e9e3fae53fb7123ef8f53f45dc18fc8fc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class BackupWorker
  include Sidekiq::Worker

  sidekiq_options queue: 'pull'

  def perform(backup_id)
    backup = Backup.find(backup_id)
    user   = backup.user

    BackupService.new.call(backup)

    user.backups.where.not(id: backup.id).destroy_all
    UserMailer.backup_ready(user, backup).deliver_later
  end
end