Improve readability

This commit is contained in:
Artur Beljajev 2018-01-23 18:47:00 +02:00
parent fed0119535
commit 404932316d

View file

@ -40,17 +40,17 @@ module Concerns::Domain::Transferable
def transfer_domain_contacts(new_registrar) def transfer_domain_contacts(new_registrar)
copied_ids = [] copied_ids = []
contacts.each do |c| contacts.each do |contact|
next if copied_ids.include?(c.id) || c.registrar == new_registrar next if copied_ids.include?(contact.id) || contact.registrar == new_registrar
if registrant_id_was == c.id # registrant was copied previously, do not copy it again if registrant_id_was == contact.id # registrant was copied previously, do not copy it again
oc = OpenStruct.new(id: registrant_id) oc = OpenStruct.new(id: registrant_id)
else else
oc = c.transfer(new_registrar) oc = contact.transfer(new_registrar)
end end
domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id }) # n+1 workaround domain_contacts.where(contact_id: contact.id).update_all({ contact_id: oc.id }) # n+1 workaround
copied_ids << c.id copied_ids << contact.id
end end
end end
end end