Sha256: 11f6854448de33947d9bf5043f8710a6f2854583f8198f04de810e10b64d73e5

Contents?: true

Size: 696 Bytes

Versions: 109

Compression:

Stored size: 696 Bytes

Contents

##
## EmailContext is mongoid
##
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

109 entries across 109 versions & 1 rubygems

Version Path
ish_manager-0.1.8.361 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.360 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.359 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.358 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.357 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.356 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.355 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.354 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.353 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.352 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.351 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.350 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.349 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.348 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.347 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.346 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.345 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.344 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.343 app/jobs/ish_manager/email_campaign_job.rb
ish_manager-0.1.8.342 app/jobs/ish_manager/email_campaign_job.rb