parent
5a7352db72
commit
87ad4c1342
@ -0,0 +1,20 @@
|
|||||||
|
namespace :user do
|
||||||
|
task :update_login => :environment do
|
||||||
|
begin
|
||||||
|
user_count = ENV['args'].split(",")[0].to_i # 更新的用户数
|
||||||
|
status = ENV['args'].split(",")[1] # 测试用户类型
|
||||||
|
base_login = ENV['args'].split(",")[2] # 基本的用户参数
|
||||||
|
|
||||||
|
users = User.where(:is_test => status).limit(user_count)
|
||||||
|
users.each_with_index do |user, i|
|
||||||
|
puts i
|
||||||
|
|
||||||
|
no = sprintf("%04d", i)
|
||||||
|
login = "#{base_login}#{no}"
|
||||||
|
user.update_attribute(:login, login)
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
Rails.logger.error(e.message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue