Module: Services::SltcProviderChangeNotifier

Defined in:
app/roles/services/sltc_provider_change_notifier.rb

Instance Method Summary collapse

Instance Method Details

#notifyObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/roles/services/sltc_provider_change_notifier.rb', line 5

def notify
  requiring_notification = ProviderChange.
    where(status: ProviderChange::STATUS_NEW).
    order("configured_account_id ASC, verb ASC")

  return if requiring_notification.empty?

  ServicesMailer.notify_sltc_provider_changes(requiring_notification).deliver 

  ids = requiring_notification.pluck(:id)
  
  # Mark these guys as reported
  ProviderChange.
    connection.
    execute("UPDATE services_provider_changes SET status = #{Services::ProviderChange::STATUS_REPORTED} WHERE id IN (#{ids.join(',')})")

end