From f4e2f6c4ffe2a1c1c23f38bfb272402896c579c8 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 29 Sep 2015 10:03:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=88=AA=E6=AD=A2=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=B6=88=E6=81=AF=E6=97=B6=E9=97=B4=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=8C=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/homework_endtime.rake | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/tasks/homework_endtime.rake b/lib/tasks/homework_endtime.rake index 1a400dc32..d5d894122 100644 --- a/lib/tasks/homework_endtime.rake +++ b/lib/tasks/homework_endtime.rake @@ -3,16 +3,14 @@ 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) - # 发送邮件通知 - Mailer.homework_endtime__added(homework_common, s.student_id).deliver - end + 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