Small fixes to import base.
This commit is contained in:
parent
1f6e40eebe
commit
6c6d406e63
|
@ -246,7 +246,7 @@ class ImportScripts::Base
|
||||||
failed += 1
|
failed += 1
|
||||||
puts "Failed to create user id: #{import_id}, username: #{new_user.username}, email: #{new_user.email}"
|
puts "Failed to create user id: #{import_id}, username: #{new_user.username}, email: #{new_user.email}"
|
||||||
puts "user errors: #{new_user.errors.full_messages}"
|
puts "user errors: #{new_user.errors.full_messages}"
|
||||||
puts "user_profile errors: #{new_user.user_profiler.errors.full_messages}"
|
puts "user_profile errors: #{new_user.user_profile.errors.full_messages}" if new_user.user_profile.present? && new_user.user_profile.errors.present?
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
failed += 1
|
failed += 1
|
||||||
|
@ -273,6 +273,10 @@ class ImportScripts::Base
|
||||||
location = opts.delete(:location)
|
location = opts.delete(:location)
|
||||||
avatar_url = opts.delete(:avatar_url)
|
avatar_url = opts.delete(:avatar_url)
|
||||||
|
|
||||||
|
# Allow the || operations to work with empty strings ''
|
||||||
|
opts[:name] = nil if opts[:name].blank?
|
||||||
|
opts[:username] = nil if opts[:username].blank?
|
||||||
|
|
||||||
opts[:name] = User.suggest_name(opts[:email]) unless opts[:name]
|
opts[:name] = User.suggest_name(opts[:email]) unless opts[:name]
|
||||||
if opts[:username].blank? ||
|
if opts[:username].blank? ||
|
||||||
opts[:username].length < User.username_length.begin ||
|
opts[:username].length < User.username_length.begin ||
|
||||||
|
@ -317,7 +321,7 @@ class ImportScripts::Base
|
||||||
u = existing
|
u = existing
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Error on record: #{opts}"
|
puts "Error on record: #{opts.inspect}"
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue