diff --git a/app/models/legacy/domain_history.rb b/app/models/legacy/domain_history.rb index bbe33aaa0..e052c4616 100644 --- a/app/models/legacy/domain_history.rb +++ b/app/models/legacy/domain_history.rb @@ -210,7 +210,7 @@ module Legacy class << self def changes_dates_for domain_id - sql = %Q{SELECT dh.*, valid_from + sql = %Q{SELECT dh.*, valid_from, valid_to FROM domain_history dh JOIN history h ON dh.historyid=h.id where dh.id=#{domain_id};} hash = {} diff --git a/lib/tasks/import_history.rake b/lib/tasks/import_history.rake index 5b6e80230..51cc04ed2 100644 --- a/lib/tasks/import_history.rake +++ b/lib/tasks/import_history.rake @@ -113,7 +113,10 @@ namespace :import do desc 'Import domain history' task history_domains: :environment do - parallel_import(Legacy::DomainHistory.uniq.pluck(:id)) do |legacy_domain_id| + old_ids = Legacy::DomainHistory.uniq.pluck(:id) + old_size = old_ids.size + parallel_import(old_ids) do |legacy_domain_id, process_idx| + start = Time.now.to_f Domain.transaction do domain = Domain.find_by(legacy_id: legacy_domain_id) version_domain = DomainVersion.where("object->>'legacy_id' = '#{legacy_domain_id}'").select(:item_id).first @@ -183,8 +186,8 @@ namespace :import do end end end + puts "[PID: #{Process.pid}] Legacy Domain #{legacy_domain_id} (#{process_idx}/#{old_size}) finished in #{Time.now.to_f - start}" end - end