Sha256: 1fb3efcfe1f3ffafb05079873750dd22a7de388ea5023b16e9820e15a058f96c

Contents?: true

Size: 736 Bytes

Versions: 68

Compression:

Stored size: 736 Bytes

Contents

##
## EmailContext is mongoid
## unused? campaigns are just contexts.
##
class IshManager::EmailCampaignJob
  include Sidekiq::Job
  queue_as :mailers

  def perform campaign_id
    @ctx = @campaign = ::Ish::EmailContext.find campaign_id
    print "Sending #{@campaign.slug}:"

    if @ctx.email_template.type != 'partial'
      raise "only `partial` template type is supported for campaigns."
    end

    if @ctx.sent_at
      raise 'This campaign has already been sent!'
    end

    @ctx.campaign_leads.each do |campaign_lead|
      IshManager::OfficeMailer.send_campaign_email( campaign_id, campaign_lead.id ).deliver_later
      print '.'
    end

    @campaign.update_attributes({ sent_at: Time.now })

    puts 'ok'
  end

end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
ish_manager-0.1.8.513 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.512 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.511 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.510 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.509 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.508 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.507 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.506 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.505 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.504 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.503 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.500 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.499 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.498 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.497 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.496 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.495 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.494 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.493 app/jobs/ish_manager/email_campaign_job.rb-trash
ish_manager-0.1.8.492 app/jobs/ish_manager/email_campaign_job.rb-trash