Class: Octo::Mailer::SubscriberMailer

Inherits:
Object
  • Object
show all
Defined in:
lib/octocore-mongo/mailer/subscriber_mailer.rb

Instance Method Summary collapse

Instance Method Details

#perform(from = nil) ⇒ Object

Method for the scheduler to call Counts the number of subscriber in the last 24 hours

and then sends a mail with subscriber count to the
email mentioned


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/octocore-mongo/mailer/subscriber_mailer.rb', line 13

def perform (from=nil)
if from.nil?
  subscribers = Octo::Subscriber.where(created_at: 24.hours.ago..Time.now.floor)
else
  subscribers = Octo::Subscriber.where(created_at: from..Time.now.floor)
end
#   MAIL CODE
Octo.get_config(:email_to).each { |x|
  opts1 = {
      text: "Today number of new susbcribes are " + subscribers.length,
      name: x.fetch('name')
  }
  Octo::Email.send(x.fetch('email'), subject, opts1)
}
end