Merge pull request #1807 from internetee/remove-registrant-api-contact-links

Registrant API: Optimize contact link(s) query
This commit is contained in:
Timo Võhmar 2021-01-21 21:10:04 +02:00 committed by GitHub
commit ae6e1d7ff1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 3 deletions

View file

@ -360,9 +360,11 @@ class Contact < ApplicationRecord
@desc
end
# Limits returned objects to 11
def related_domains
a = related_domain_descriptions
a.keys.map { |d| { name: d, id: a[d][:id], roles: a[d][:roles] } }
ids = DomainContact.select(:domain_id).where(contact_id: id).limit(11).map(&:domain_id).uniq
res = Domain.where(id: ids).or(Domain.where(registrant_id: id)).select(:name, :uuid).limit(11)
res.pluck(:name, :uuid).map { |name, id| { name: name, id: id } }
end
def status_notes_array=(notes)