|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
# encoding: utf-8
|
|
|
|
class CreateShixunStudentWorks < ActiveRecord::Migration
|
|
|
|
class CreateShixunStudentWorks < ActiveRecord::Migration
|
|
|
|
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
|
|
|
|
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
|
|
|
|
|
|
|
|
|
|
|
@ -13,16 +14,16 @@ class CreateShixunStudentWorks < ActiveRecord::Migration
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def up
|
|
|
|
def up
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and (work_score is null or work_score = 0)")
|
|
|
|
begin
|
|
|
|
works.update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil,
|
|
|
|
works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and (work_score is null or work_score = 0)")
|
|
|
|
:cost_time => 0, :update_time => nil, :compelete_status => 0, :commit_time => nil)
|
|
|
|
works.update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil,
|
|
|
|
|
|
|
|
:cost_time => 0, :update_time => nil, :compelete_status => 0, :commit_time => nil)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shixun_works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and work_score > 0")
|
|
|
|
shixun_works = StudentWork.where("myshixun_id != 0 and myshixun_id not in (select id from myshixuns) and work_score > 0")
|
|
|
|
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
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
if shixun.present? && user.present?
|
|
|
|
if shixun.present? && user.present?
|
|
|
|
# 创建新的myshixun和games
|
|
|
|
# 创建新的myshixun和games
|
|
|
|
# fork版本库,如果用户没有同步,则先同步用户
|
|
|
|
# fork版本库,如果用户没有同步,则先同步用户
|