Class: CommunicationWorker
- Inherits:
-
Object
- Object
- CommunicationWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/communication_worker.rb
Overview
Sidekiq worker: communication.
Instance Method Summary collapse
Instance Method Details
#perform(communication_ids = []) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/workers/communication_worker.rb', line 9 def perform(communication_ids = []) communication_ids = [communication_ids].compact.flatten if communication_ids.present? logger.info "Communication Worker processing communication id(s): #{communication_ids.join(',')}" Communication.non_campaign.where(state: 'queued').where(id: communication_ids).find_each do |communication| logger.info "Found queued communication id : #{communication.id}, attempting release" communication.release logger.info "Done sending communication id : #{communication.id}, new state is #{communication.state}, status is #{communication.}" end else # Enqueuing mode communication_ids = Communication.non_campaign.where(state: 'queued').where('transmit_at IS NULL or transmit_at <= ?', Time.current).order(:created_at).ids communication_ids.each do |cid| logger.info "Communication worker enqueuing communication worker with communication id #{cid}" CommunicationWorker.perform_async(cid) end end end |