Class: WcoEmail::Campaign
- Inherits:
-
Object
- Object
- WcoEmail::Campaign
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/wco_email/campaign.rb
Overview
Sends a campaign. vp 2023-02-02
Constant Summary collapse
- PAGE_PARAM_NAME =
'email_contexts_page'
Instance Attribute Summary collapse
-
#tid ⇒ Object
readonly
For tracking.
Instance Method Summary collapse
Instance Attribute Details
#tid ⇒ Object (readonly)
For tracking
41 42 43 |
# File 'app/models/wco_email/campaign.rb', line 41 def tid @tid end |
Instance Method Details
#campaign_leads ⇒ Object
30 31 32 |
# File 'app/models/wco_email/campaign.rb', line 30 def campaign_leads return ::EmailCampaignLead.where( email_campaign_id: self.id.to_s ).includes( :lead ) end |
#do_send ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/wco_email/campaign.rb', line 43 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 |
#leads ⇒ Object
34 35 36 |
# File 'app/models/wco_email/campaign.rb', line 34 def leads ::Lead.joins( :email_campaign_leads ).where( 'email_campaign_leads.email_campaign_id' => self.id.to_s ) end |
#tmpl ⇒ Object
20 |
# File 'app/models/wco_email/campaign.rb', line 20 def tmpl; email_template; end |