mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
parent
c733c0910d
commit
ecc68f083d
3 changed files with 67 additions and 25 deletions
|
@ -1,18 +1,34 @@
|
|||
module Concerns::Contact::Identical
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ATTRIBUTE_FILTER = %w[
|
||||
IDENTIFIABLE_ATTRIBUTES = %w[
|
||||
name
|
||||
email
|
||||
phone
|
||||
fax
|
||||
ident
|
||||
ident_type
|
||||
ident_country_code
|
||||
phone
|
||||
email
|
||||
org_name
|
||||
]
|
||||
private_constant :ATTRIBUTE_FILTER
|
||||
private_constant :IDENTIFIABLE_ATTRIBUTES
|
||||
|
||||
def identical(registrar)
|
||||
self.class.where(attributes.slice(*ATTRIBUTE_FILTER)).where(registrar: registrar)
|
||||
self.class.where(identifiable_hash)
|
||||
.where(["statuses = ?::character varying[]", "{#{read_attribute(:statuses).join(',')}}"])
|
||||
.where(registrar: registrar)
|
||||
.where.not(id: id).take
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def identifiable_hash
|
||||
attributes = IDENTIFIABLE_ATTRIBUTES
|
||||
|
||||
if self.class.address_processing?
|
||||
attributes += self.class.address_attribute_names
|
||||
end
|
||||
|
||||
slice(*attributes)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue