FEATURE: phase 1 of supporting multiple email addresses

This commit is contained in:
Leo McArdle
2017-04-26 19:47:36 +01:00
committed by Guo Xiang Tan
parent 739794f0cb
commit d0b027d88d
35 changed files with 337 additions and 80 deletions

View File

@ -93,7 +93,7 @@ class BulkImport::Base
puts "Loading users indexes..."
@last_user_id = User.unscoped.maximum(:id)
@emails = User.unscoped.pluck(:email).to_set
@emails = User.unscoped.pluck(:"user_emails.email").to_set
@usernames_lower = User.unscoped.pluck(:username_lower).to_set
@mapped_usernames = UserCustomField.joins(:user).where(name: "import_username").pluck("user_custom_fields.value", "users.username").to_h

View File

@ -324,7 +324,7 @@ class ImportScripts::Base
rescue => e
# try based on email
if e.try(:record).try(:errors).try(:messages).try(:[], :email).present?
if existing = User.find_by(email: opts[:email].downcase)
if existing = User.find_by_email(opts[:email].downcase)
existing.custom_fields["import_id"] = import_id
existing.save!
u = existing