|
|
@ -13,7 +13,6 @@ class CreateShixunStudentWorks < ActiveRecord::Migration
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def up
|
|
|
|
def up
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and (work_score is null or work_score = 0)")
|
|
|
|
works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and (work_score is null or work_score = 0)")
|
|
|
|
works.update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil,
|
|
|
|
works.update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil,
|
|
|
@ -23,6 +22,7 @@ class CreateShixunStudentWorks < ActiveRecord::Migration
|
|
|
|
shixun_works.each do |work|
|
|
|
|
shixun_works.each do |work|
|
|
|
|
shixun = work.homework_common.try(:homework_commons_shixuns).try(:shixun)
|
|
|
|
shixun = work.homework_common.try(:homework_commons_shixuns).try(:shixun)
|
|
|
|
user = work.user
|
|
|
|
user = work.user
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
if shixun.present? && user.present?
|
|
|
|
if shixun.present? && user.present?
|
|
|
|
# 创建新的myshixun和games
|
|
|
|
# 创建新的myshixun和games
|
|
|
|
# fork版本库,如果用户没有同步,则先同步用户
|
|
|
|
# fork版本库,如果用户没有同步,则先同步用户
|
|
|
@ -80,13 +80,13 @@ class CreateShixunStudentWorks < ActiveRecord::Migration
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
puts ("###failed to exec shixun: current task id is #{e}")
|
|
|
|
puts ("###failed to exec shixun: current task id is #{e}")
|
|
|
|
# g.delete_project(gshixun.id) if gshixun.try(:id).present?
|
|
|
|
# g.delete_project(gshixun.id) if gshixun.try(:id).present?
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def down
|
|
|
|
def down
|
|
|
|
end
|
|
|
|
end
|