From 8d23815169277a61420f94e59f9675dfb995bf2a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 2 Jun 2015 11:42:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E4=B8=8D?= =?UTF-8?q?=E5=AE=8C=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20150602021020_add_score_to_work.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/migrate/20150602021020_add_score_to_work.rb b/db/migrate/20150602021020_add_score_to_work.rb index 93045793c..446a5a4f7 100644 --- a/db/migrate/20150602021020_add_score_to_work.rb +++ b/db/migrate/20150602021020_add_score_to_work.rb @@ -2,8 +2,9 @@ class AddScoreToWork < ActiveRecord::Migration require 'bigdecimal' def up + count = StudentWork.all.count / 10 + 1 transaction do - for i in 1 ... 1000 do i + for i in 1 ... count do i StudentWork.page(i).per(10).each do |work| teacher_score = work.student_works_scores.where(:reviewer_role => 1).order("created_at desc") unless teacher_score.empty? @@ -43,8 +44,9 @@ class AddScoreToWork < ActiveRecord::Migration end def down + count = StudentWork.all.count / 10 + 1 transaction do - for i in 1 ... 1000 do i + for i in 1 ... count do i StudentWork.page(i).per(10).each do |work| work.teacher_score = nil work.teaching_asistant_score = nil