mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +02:00
Optimize contact linked status update #2477
This commit is contained in:
parent
8700beea60
commit
48bc4d4ac9
3 changed files with 48 additions and 19 deletions
|
@ -16,10 +16,20 @@ class Epp::Domain < Domain
|
|||
false
|
||||
end
|
||||
|
||||
before_save :update_contact_status
|
||||
def update_contact_status
|
||||
contacts.each do |c|
|
||||
next if c.linked?
|
||||
before_save :link_contacts
|
||||
def link_contacts
|
||||
# Based on bullet report
|
||||
unlinked_contacts = contacts.select { |c| !c.linked? } # speed up a bit
|
||||
unlinked_contacts.each do |uc|
|
||||
uc.domains_present = true # no need to fetch domains again
|
||||
uc.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
after_destroy :unlink_contacts
|
||||
def unlink_contacts
|
||||
contacts.each do |c|
|
||||
c.domains_present = false
|
||||
c.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue