Send monthly reports

This commit is contained in:
Aart van Halteren
2023-02-21 22:43:22 +01:00
parent ccb8589a4b
commit 534e8dc294
4 changed files with 182 additions and 12 deletions

View File

@@ -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