From 3f60893591a4316c3d96956c09d45a0f37239dba Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 12 Nov 2015 14:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E7=94=A8=E5=8C=BF=E8=AF=84=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=9C=A8=E6=88=AA=E6=AD=A2=E6=97=B6=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=8A=B6=E6=80=81=E5=8F=98=E4=B8=BA3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/homework_publishtime.rake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index 4d79086d4..8e231fafd 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -1,7 +1,7 @@ #coding=utf-8 namespace :homework_publishtime do - desc "start publish homework" + desc "start publish homework and end homework" task :publish => :environment do homework_commons = HomeworkCommon.where("publish_time = '#{Date.today}'") homework_commons.each do |homework| @@ -20,4 +20,16 @@ namespace :homework_publishtime do end end end + + task :end => :environment do + homework_commons = HomeworkCommon.where("end_time < '#{Date.today}'") + homework_commons.each do |homework| + if homework.anonymous_comment == 1 + homework_detail_manual = homework.homework_detail_manual + if homework_detail_manual.comment_status == 1 + homework_detail_manual.update_column('comment_status', 3) + end + end + end + end end \ No newline at end of file