Class: Webhookdb::Jobs::OrganizationDatabaseMigrationNotifyStarted

Inherits:
Object
  • Object
show all
Extended by:
Async::Job
Defined in:
lib/webhookdb/jobs/organization_database_migration_notify_started.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_started.rb', line 11

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