Class: CampaignCommunicationWorker
- Inherits:
-
Object
- Object
- CampaignCommunicationWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/campaign_communication_worker.rb
Overview
Sidekiq worker: campaign 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/campaign_communication_worker.rb', line 9 def perform(communication_ids = []) communication_ids = [communication_ids].compact.flatten if communication_ids.present? logger.info "Campaign Communication Worker processing communication id(s): #{communication_ids.join(',')}" Communication.campaign_only.where(state: 'queued').where(id: communication_ids).find_each do |communication| logger.info "Found queued campaign communication id : #{communication.id}, attempting release" communication.release logger.info "Done sending campaign communication id : #{communication.id}, new state is #{communication.state}, status is #{communication.}" end else # Enqueuing mode communication_ids = Communication.campaign_only.where(state: 'queued').where('transmit_at IS NULL or transmit_at <= ?', Time.current).order(id: :asc).ids communication_ids.each do |cid| logger.info "Campaign Communication worker enqueuing campaign communication worker with communication id #{cid}" CampaignCommunicationWorker.perform_async(cid) end end end |