parent
13557bb96f
commit
f064afdd46
@ -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