19 lines
822 B
Ruby
19 lines
822 B
Ruby
#coding=utf-8
|
|
|
|
namespace :homework_endtime do
|
|
desc "send a message for Job deadline"
|
|
task :message => :environment do
|
|
contrast_time = Time.now + 86400
|
|
homework_commons = HomeworkCommon.where("end_time <=? and end_time >=?",contrast_time, Time.now)
|
|
homework_commons.each do |homework_common|
|
|
if CourseMessage.where("course_message_type =? and course_message_id =? and status =?", "HomeworkCommon", homework_common.id, 1).count == 0
|
|
homework_common.course.student.each do |s|
|
|
homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true)
|
|
# 发送邮件通知
|
|
# Mailer.homework_endtime__added(homework_common, s.student_id).deliver
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|