Merge branch 'szzh' into develop

This commit is contained in:
huang 2015-11-20 09:30:03 +08:00
commit e172952b2a
2 changed files with 14 additions and 8 deletions

View File

@ -3,7 +3,7 @@ class CopyForgeActivitiesToOrgActivities < ActiveRecord::Migration
count = ForgeActivity.all.count/30 + 1
for i in 1 ... count do
transaction do
ForgeActivity.page(i).per(30).each do
ForgeActivity.page(i).per(30).each do |forge_act|
OrgActivity.create(:user_id => forge_act.user_id,
:org_act_id => forge_act.forge_act_id,
:org_act_type => forge_act.forge_act_type,

View File

@ -4,13 +4,19 @@ class CopyCourseActivitiesToOrgActivities < ActiveRecord::Migration
for i in 1 ... count do
transaction do
CourseActivity.page(i).per(30).each do |course_act|
OrgActivity.create(:user_id => course_act.user_id,
:org_act_type => course_act.course_act_type,
:org_act_id => course_act.course_act_id,
:container_id => course_act.course_id,
:container_type => "Course",
:created_at => course_act.created_at,
:updated_at => course_act.updated_at)
if course_act.course_act_type == 'Message' && !course_act.course_act.parent_id.nil?
org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{course_act.course_act.parent.id}").first
org_activity.created_at = course_act.created_at
org_activity.save
else
OrgActivity.create(:user_id => course_act.user_id,
:org_act_id => course_act.course_act_id,
:org_act_type => course_act.course_act_type,
:container_id => course_act.course_id,
:container_type => 'Course',
:created_at => course_act.created_at,
:updated_at => course_act.updated_at)
end
end
end
end