From f064afdd46e70f0568efa0651425a29fc27f0c94 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 24 Jul 2019 12:31:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=9F=A5=E7=9C=8B=E7=AD=94?= =?UTF-8?q?=E6=A1=88=E8=AE=B0=E5=BD=95=E6=89=A3=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20190724013024_modify_final_score_for_games.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/migrate/20190724013024_modify_final_score_for_games.rb diff --git a/db/migrate/20190724013024_modify_final_score_for_games.rb b/db/migrate/20190724013024_modify_final_score_for_games.rb new file mode 100644 index 000000000..e926cccd6 --- /dev/null +++ b/db/migrate/20190724013024_modify_final_score_for_games.rb @@ -0,0 +1,15 @@ +class ModifyFinalScoreForGames < ActiveRecord::Migration[5.2] + def change + grades = Grade.where(container_type: "Answer") + grades.each do |grade| + g = Game.find_by_id(grade.container_id) + if g.present? + if g.status == 2 && g.answer_open > 0 && g.final_score <= 0 && g.end_time < grade.created_at + g.update_column(:final_score, g.challenge.score) + elsif g.final_score < 0 + g.update_column(:final_score, 0) + end + end + end + end +end