intercity/intercity-next

View on GitHub
app/models/backup_scheduler.rb

Summary

Maintainability
A
45 mins
Test Coverage
class BackupScheduler
  def initialize(app)
    @app = app
  end

  def execute(type: :manual)
    app.services.each do |service|
      next unless service.commands["backup"]
      next unless app.server.up?
      backup = app.backups.create!(service: service, running: true,
                                   backup_type: type.to_s)
      CreateBackupJob.perform_later(backup)
    end
  end

  private

  attr_accessor :app
end