积分初始数据迁移
This commit is contained in:
parent
640dd285c1
commit
eaed13dbc8
|
|
@ -0,0 +1,22 @@
|
|||
class SyncGradeForUser < ActiveRecord::Migration
|
||||
def change
|
||||
count = User.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
User.page(i).per(30).each do |u|
|
||||
if u.user_extensions
|
||||
unless u.user_extensions.try(:school).nil?
|
||||
Grade.create(:user_id => u.id, :container_id => u.id, :container_type => "Account", :score => 500)
|
||||
end
|
||||
end
|
||||
if !u.mail.nil?
|
||||
Grade.create(:user_id => u.id, :container_id => u.id, :container_type => "Mail", :score => 500)
|
||||
end
|
||||
if !u.phone.nil?
|
||||
Grade.create(:user_id => u.id, :container_id => u.id, :container_type => "Phone", :score => 500)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue