将每日邮件移入crontab
This commit is contained in:
parent
51dbc43ecf
commit
77134c8dde
|
@ -1,12 +1,15 @@
|
|||
#coding=utf-8
|
||||
|
||||
scheduler = Rufus::Scheduler.new
|
||||
|
||||
#每天18:00发送当天的邮件汇总
|
||||
scheduler.cron('0 18 * * *') do
|
||||
users = User.where(mail_notification: 'day')
|
||||
users.each do |user|
|
||||
mailer = Mailer.send_for_user_activities(user, Date.today, 1)
|
||||
mailer.deliver if mailer
|
||||
end
|
||||
end
|
||||
## 移入crontab
|
||||
|
||||
# scheduler = Rufus::Scheduler.new
|
||||
#
|
||||
# #每天18:00发送当天的邮件汇总
|
||||
# scheduler.cron('0 18 * * *') do
|
||||
# users = User.where(mail_notification: 'day')
|
||||
# users.each do |user|
|
||||
# mailer = Mailer.send_for_user_activities(user, Date.today, 1)
|
||||
# mailer.deliver if mailer
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -194,5 +194,14 @@ END_DESC
|
|||
abort l(:notice_email_error, e.message)
|
||||
end
|
||||
end
|
||||
|
||||
desc "send a email for day"
|
||||
task :day => :environment do
|
||||
users = User.where(mail_notification: 'day')
|
||||
users.each do |user|
|
||||
mailer = Mailer.send_for_user_activities(user, Date.today, 1)
|
||||
mailer.deliver if mailer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue