Merge branches 'dev_aliyun' and 'master' of https://bdgit.educoder.net/Hjqreturn/educoder
commit
e4c44d4a16
@ -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
|
Loading…
Reference in new issue