From 57d6a5dc9c6aaa3f9bfa99adf3b6e18f2258d78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 24 Jul 2017 14:22:00 +0200 Subject: [PATCH] FIX: vBulletin bulk importer --- script/bulk_import/base.rb | 4 ++-- script/bulk_import/vbulletin.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb index 63d7041cb41..ce29ac3d990 100644 --- a/script/bulk_import/base.rb +++ b/script/bulk_import/base.rb @@ -93,7 +93,7 @@ class BulkImport::Base puts "Loading users indexes..." @last_user_id = User.unscoped.maximum(:id) - @emails = User.unscoped.pluck(:"user_emails.email").to_set + @emails = User.unscoped.joins(:user_emails).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 @@ -138,7 +138,7 @@ class BulkImport::Base } USER_COLUMNS ||= %i{ - id username username_lower name email active trust_level admin moderator + id username username_lower name active trust_level admin moderator date_of_birth ip_address registration_ip_address primary_group_id suspended_at suspended_till last_emailed_at created_at updated_at } diff --git a/script/bulk_import/vbulletin.rb b/script/bulk_import/vbulletin.rb index 2121a47b2d3..3d33616b2d6 100644 --- a/script/bulk_import/vbulletin.rb +++ b/script/bulk_import/vbulletin.rb @@ -360,7 +360,8 @@ class BulkImport::VBulletin < BulkImport::Base def parse_birthday(birthday) return if birthday.blank? - date_of_birth = Date.strptime(birthday, "%m-%d-%Y") + date_of_birth = Date.strptime(birthday.gsub(/[^\d-]+/, ""), "%m-%d-%Y") rescue nil + return if date_of_birth.nil? date_of_birth.year < 1904 ? Date.new(1904, date_of_birth.month, date_of_birth.day) : date_of_birth end