diff --git a/app/models/legacy/domain.rb b/app/models/legacy/domain.rb index 949a14702..c17033c29 100644 --- a/app/models/legacy/domain.rb +++ b/app/models/legacy/domain.rb @@ -30,5 +30,11 @@ module Legacy @new_registrar_cache ||= {} @new_registrar_cache[old_id] ||= ::Registrar.select(:id).find_by(legacy_id: old_id) end + + def self.new_api_user_cached old_id + @new_api_user_cache ||= {} + @new_api_user_cache[old_id] ||= Legacy::Domain.new_registrar_cached(old_id).try(:api_users).try(:first) + end + end end diff --git a/app/models/legacy/domain_history.rb b/app/models/legacy/domain_history.rb index 4b75b81da..bbe33aaa0 100644 --- a/app/models/legacy/domain_history.rb +++ b/app/models/legacy/domain_history.rb @@ -55,7 +55,7 @@ module Legacy def user @user ||= begin obj_his = Legacy::ObjectHistory.find_by(historyid: historyid) - Legacy::Domain.new_registrar_cached(obj_his.upid || obj_his.clid).try(:api_users).try(:first) + Legacy::Domain.new_api_user_cached(obj_his.upid || obj_his.clid) end end diff --git a/lib/tasks/import_history.rake b/lib/tasks/import_history.rake index 535ef55ec..0f41d0a5c 100644 --- a/lib/tasks/import_history.rake +++ b/lib/tasks/import_history.rake @@ -57,7 +57,7 @@ namespace :import do end next if changes.blank? && event != :destroy obj_his = Legacy::ObjectHistory.find_by(historyid: responder.historyid) - user = Legacy::Domain.new_registrar_cached(obj_his.upid || obj_his.clid).try(:api_users).try(:first) + user = Legacy::Domain.new_api_user_cached(obj_his.upid || obj_his.clid) hash = { item_type: Contact.to_s,