Class: Webhookdb::Jobs::OrganizationDatabaseMigrationNotifyFinished

Inherits:
Object
  • Object
show all
Extended by:
Async::Job
Defined in:
lib/webhookdb/jobs/organization_database_migration_notify_finished.rb

Instance Method Summary collapse

Methods included from Async::Job

extended

Instance Method Details

#_perform(event) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/webhookdb/jobs/organization_database_migration_notify_finished.rb', line 11

def _perform(event)
  dbm = self.lookup_model(Webhookdb::Organization::DatabaseMigration, event)
  case event.payload[1]
    when changed(:finished_at, from: nil)
      Webhookdb::Idempotency.once_ever.under_key("org-dbmigration-finish-#{dbm.id}") do
        msg = Webhookdb::Messages::OrgDatabaseMigrationFinished.new(dbm)
        dbm.organization.admin_customers.each { |c| msg.dispatch_email(c) }
      end
  end
end