From e64622b372e5fe368a9b91777d13349b0cd3e6c5 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 7 Apr 2015 10:29:50 +0300 Subject: [PATCH] Replace contact name with org when name is empty --- lib/tasks/import.rake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index c378aa5d0..c3ecec2ab 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -23,30 +23,30 @@ namespace :import do # in console: Legacy::Contact.last # in console: exit # - # In console you should get Last Legacy::Contact object. + # In console you should get Last Legacy::Contact object. # If you get any errors, scroll up and read first lines # to figure out what went wrong to connect to fred database. # # # 2) START IMPORT # --------------- - # + # # Import scrip does not write anything to fred database. # Script is implemented this way, you can run it multiple times # in case you need it. However already imported object are # not reimported, thus if some object has been updated meanwhile # in fred database, those updates will be missed and thous should - # be carried over manually. All new object in fred will be + # be carried over manually. All new object in fred will be # imported in multiple import script runs. # # Start all import: - # + # # cd your_registry_deploy_path/current/ # RAILS_ENV=production bundle exec rails import:all - # + # # If you wish to import one by one, please follow individual import order # from task 'Import all' tasks in this script. - + desc 'Import all' task all: :environment do Rake::Task['import:registrars'].invoke @@ -148,6 +148,7 @@ namespace :import do next if existing_contact_ids.include?(x.id) count += 1 + name = x.name.try(:strip).presence || x.organization.try(:strip).presence begin contacts << [ x.object_registry.name.try(:strip), @@ -158,7 +159,7 @@ namespace :import do x.ssn.try(:strip), ident_type_map[x.ssntype], x.object.authinfopw.try(:strip), - x.name.try(:strip), + name, x.organization.try(:strip), x.object_registry.try(:registrar).try(:id), user,