parent
7e87cd2f82
commit
9aedab22d8
@ -0,0 +1,93 @@
|
||||
class MigrateHomeworkEndTime < ActiveRecord::Migration
|
||||
def up
|
||||
homework = HomeworkCommon.where(id: 18615).first
|
||||
if homework.present?
|
||||
transaction do
|
||||
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '#{homework.end_time}'").each do |work|
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
score = work.final_score + work.eff_score - work.late_penalty
|
||||
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homework = HomeworkCommon.where(id: 18614).first
|
||||
if homework.present?
|
||||
homework.update_column('end_time', '2019-05-20 00:00:00')
|
||||
transaction do
|
||||
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-20 00:00:00'").each do |work|
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
score = work.final_score + work.eff_score - work.late_penalty
|
||||
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homework = HomeworkCommon.where(id: 18617).first
|
||||
if homework.present?
|
||||
homework.update_column('end_time', '2019-05-29 00:00:00')
|
||||
homework.save
|
||||
transaction do
|
||||
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-29 00:00:00'").each do |work|
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
score = work.final_score + work.eff_score - work.late_penalty
|
||||
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homework = HomeworkCommon.where(id: 18616).first
|
||||
if homework.present?
|
||||
homework.update_column('end_time', '2019-06-10 00:00:00')
|
||||
homework.save
|
||||
transaction do
|
||||
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-10 00:00:00'").each do |work|
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
score = work.final_score + work.eff_score - work.late_penalty
|
||||
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homework = HomeworkCommon.where(id: 25901).first
|
||||
if homework.present?
|
||||
homework.update_column('end_time', '2019-06-16 00:00:00')
|
||||
homework.save
|
||||
transaction do
|
||||
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-16 00:00:00'").each do |work|
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
score = work.final_score + work.eff_score - work.late_penalty
|
||||
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homework = HomeworkCommon.where(id: 25902).first
|
||||
if homework.present?
|
||||
homework.update_column('end_time', '2019-06-17 00:00:00')
|
||||
homework.save
|
||||
transaction do
|
||||
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-17 00:00:00'").each do |work|
|
||||
work.work_status = 1
|
||||
work.late_penalty = 0
|
||||
score = work.final_score + work.eff_score - work.late_penalty
|
||||
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
|
||||
work.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in new issue