From dc0cc0beb8029c68a300abaa3f51b77c76155206 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 30 May 2019 13:12:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...58_migrate_shixun_student_work_score_2.rb} | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) rename db/migrate/{20190530044812_migrate_shixun_student_work_score.rb => 20190530050358_migrate_shixun_student_work_score_2.rb} (50%) diff --git a/db/migrate/20190530044812_migrate_shixun_student_work_score.rb b/db/migrate/20190530050358_migrate_shixun_student_work_score_2.rb similarity index 50% rename from db/migrate/20190530044812_migrate_shixun_student_work_score.rb rename to db/migrate/20190530050358_migrate_shixun_student_work_score_2.rb index 446a2652..4eb869b4 100644 --- a/db/migrate/20190530044812_migrate_shixun_student_work_score.rb +++ b/db/migrate/20190530050358_migrate_shixun_student_work_score_2.rb @@ -1,19 +1,22 @@ -class MigrateShixunStudentWorkScore < ActiveRecord::Migration +class MigrateShixunStudentWorkScore2 < ActiveRecord::Migration def up homeworks = HomeworkCommon.where(id: [18615, 18614, 18617, 18616, 25901, 25902]) homeworks.each do |homework| transaction do - challeng_ids = homework.homework_challenge_settings.map(&:challenge_id) homework.student_works.where("work_status > 0").each do |work| - myshixun = work.myshixun - games = myshixun.games.where(:challenge_id => challeng_ids) - myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil - if myshixun_endtime.present? && myshixun_endtime < homework.end_time + if homework.end_time > Time.now work.work_status = 1 work.late_penalty = 0 - else - work.work_status = 2 - work.late_penalty = homework.late_penalty + else + myshixun = work.myshixun + + if myshixun.status == 1 && myshixun.try(:done_time) < homework.end_time + work.work_status = 1 + work.late_penalty = 0 + else + work.work_status = 2 + work.late_penalty = homework.late_penalty + end end score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score