21 lines
957 B
Ruby
21 lines
957 B
Ruby
#coding=utf-8
|
|
|
|
namespace :contest_work_endtime do
|
|
desc "send a message for work deadline"
|
|
task :message => :environment do
|
|
puts "--------------------------------contest_work_endtime start"
|
|
contrast_time = Time.now - 86400
|
|
homework_commons = Work.where("end_time >=? and end_time <=?",contrast_time, Time.now)
|
|
homework_commons.each do |homework_common|
|
|
if ContestMessage.where("contest_message_type =? and contest_message_id =? and status =?", "Work", homework_common.id, 1).first.nil?
|
|
homework_common.contest.contestants.each do |s|
|
|
homework_common.contest_messages << ContestMessage.new(:user_id => s.student_id, :contest_id => homework_common.contest_id, :viewed => false, :status => true)
|
|
# 发送邮件通知
|
|
# Mailer.homework_endtime__added(homework_common, s.student_id).deliver
|
|
end
|
|
end
|
|
end
|
|
puts "--------------------------------contest_work_endtime end"
|
|
end
|
|
end
|