socialforge/config/initializers/send_mail.rb

24 lines
595 B
Ruby
Raw Normal View History

2015-02-06 18:15:08 +08:00
#!/usr/bin/env ruby
require 'rubygems'
require 'rufus-scheduler'
#users = User.where("mail_notification = 'week' or mail_notification = 'day'")
scheduler = Rufus::Scheduler.new
scheduler.cron('*/1 * * * *') do
users = User.where("login like '%alan%'")
users.each do |user|
# if user.mail_notification == "week"
# cycle = '*/1 * * * *'
# else
# cycle = '*/2 * * * *'
# end
Rails.logger.info "send mail to #{user.show_name}(#{user.mail}) at #{Time.now}"
Thread.start do
Mailer.send_for_user_activities(user, Date.today, 7).deliver
end
end
end