Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
daiao 6 years ago
commit 39dd5bf25c

@ -47,7 +47,8 @@ module Searchable::Shixun
author_name: user.real_name,
author_school_name: user.school_name,
visits_count: visits,
challenges_count: challenges_count
challenges_count: challenges_count,
study_count: myshixuns_count
}
end

@ -19,15 +19,13 @@ class MigrateCourseMembers < ActiveRecord::Migration[5.2]
ActiveRecord::Base.transaction do
begin
Member.where("course_id != -1").find_each do |member|
if member.course && member.user
puts(member.id)
member.member_roles.each do |role|
course_member_role = role.role_id == 3 ? 1 : (role.role_id == 9 ? 2 : (role.role_id == 7 ? 3 : 4))
member_group_id = role.role_id == 10 ? member.course_group_id : 0
CourseMember.create!(course_id: member.course_id, user_id: member.user_id, course_group_id: member_group_id.to_i,
graduation_group_id: member.graduation_group_id.to_i, role: course_member_role, is_active: role.is_current)
end
Member.where("course_id != -1").includes(:member_roles).find_each(batch_size: 500) do |member|
puts(member.id)
member.member_roles.each do |role|
course_member_role = role.role_id == 3 ? 1 : (role.role_id == 9 ? 2 : (role.role_id == 7 ? 3 : 4))
member_group_id = role.role_id == 10 ? member.course_group_id : 0
CourseMember.create!(course_id: member.course_id, user_id: member.user_id, course_group_id: member_group_id,
graduation_group_id: member.graduation_group_id, role: course_member_role, is_active: role.is_current)
end
end
rescue Exception => e

Loading…
Cancel
Save