作业截止日期消息时间调整,代码优化
This commit is contained in:
parent
5b0738a4cb
commit
f4e2f6c4ff
|
@ -3,11 +3,10 @@
|
|||
namespace :homework_endtime do
|
||||
desc "send a message for Job deadline"
|
||||
task :message => :environment do
|
||||
current_day = Date.today.day
|
||||
homework_commons = HomeworkCommon.where("end_time >=?",Date.today)
|
||||
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).first.nil?
|
||||
if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year
|
||||
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)
|
||||
# 发送邮件通知
|
||||
|
@ -16,5 +15,4 @@ namespace :homework_endtime do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue