Class: Ish::EmailCampaign

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/ish/email_campaign.rb

Overview

Sends a campaign. vp 2023-02-02

Constant Summary collapse

PAGE_PARAM_NAME =
'email_contexts_page'
FROM_EMAILS =
%w|    [email protected] [email protected]
[email protected] [email protected]        [email protected]        [email protected]
[email protected]     [email protected]            [email protected]            [email protected] |

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tidObject (readonly)

For tracking



45
46
47
# File 'lib/ish/email_campaign.rb', line 45

def tid
  @tid
end

Class Method Details

.from_email_listObject



21
22
23
# File 'lib/ish/email_campaign.rb', line 21

def self.from_email_list
  [ [nil, nil] ] + FROM_EMAILS.map { |i| [i, i] }
end

Instance Method Details

#campaign_leadsObject



34
35
36
# File 'lib/ish/email_campaign.rb', line 34

def campaign_leads
  return ::EmailCampaignLead.where( email_campaign_id: self.id.to_s ).includes( :lead )
end

#do_sendObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ish/email_campaign.rb', line 47

def do_send
  leads.each do |lead|
    ctx = Ctx.create!({
      email_template: tmpl,
      from_email:     tmpl.from_email,
      lead_id:        lead.id,
      send_at:        Time.now,
      subject:        tmpl.subject,
    })
  end
end

#leadsObject



38
39
40
# File 'lib/ish/email_campaign.rb', line 38

def leads
  campaign_leads&.map { |p| p.lead }
end

#tmplObject



26
# File 'lib/ish/email_campaign.rb', line 26

def tmpl; email_template; end