Use lowercased email addresses to check duplicates
This commit is contained in:
parent
ac44374a59
commit
2a0f409b9d
|
@ -128,7 +128,7 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||||
ORDER BY user_id
|
ORDER BY user_id
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
duplicate_emails = mysql_query("SELECT email FROM users GROUP BY email HAVING COUNT(email) > 1").map { |e| [e["email"], 0] }.to_h
|
duplicate_emails = mysql_query("SELECT email_lower FROM users GROUP BY email_lower HAVING COUNT(email_lower) > 1").map { |e| [e["email_lower"], 0] }.to_h
|
||||||
|
|
||||||
create_users(users, total: user_count, offset: offset) do |user|
|
create_users(users, total: user_count, offset: offset) do |user|
|
||||||
user_id = user["id"]
|
user_id = user["id"]
|
||||||
|
@ -139,9 +139,10 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||||
username = USERNAME_MAPPINGS[username] if USERNAME_MAPPINGS[username].present?
|
username = USERNAME_MAPPINGS[username] if USERNAME_MAPPINGS[username].present?
|
||||||
|
|
||||||
email = user["email"].presence || fake_email
|
email = user["email"].presence || fake_email
|
||||||
if duplicate_emails.key?(email)
|
email_lower = email.downcase
|
||||||
duplicate_emails[email] += 1
|
if duplicate_emails.key?(email_lower)
|
||||||
email.sub!("@", "+#{duplicate_emails[email]}@")
|
duplicate_emails[email_lower] += 1
|
||||||
|
email.sub!("@", "+#{duplicate_emails[email_lower]}@")
|
||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue