Send monthly reports
This commit is contained in:
@@ -12,6 +12,13 @@ connection_details = YAML::load(File.open('config/database.yml'))
|
||||
ActiveRecord::Base.establish_connection(connection_details)
|
||||
|
||||
if __FILE__ == $0
|
||||
ReadingsMailer.deliver(Date.today.advance(days: -1))
|
||||
yesterday = Date.today.advance(days: -1)
|
||||
ReadingsMailer.deliver(yesterday)
|
||||
|
||||
# are we at the start of a month?
|
||||
if (Date.today.beginning_of_month == Date.today)
|
||||
# then also send report for previous month (and year)
|
||||
ReadingsMailer.deliver_for_month(yesterday.month, yesterday.year)
|
||||
end
|
||||
end
|
||||
#p sync
|
||||
|
||||
Reference in New Issue
Block a user