mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
parent
296442e330
commit
487613db1e
14 changed files with 424 additions and 84 deletions
|
@ -5,4 +5,41 @@ class DomainVersion < PaperTrail::Version
|
|||
self.sequence_name = :log_domains_id_seq
|
||||
|
||||
scope :deleted, -> { where(event: 'destroy') }
|
||||
end
|
||||
|
||||
def self.was_contact_linked?(contact)
|
||||
sql = <<-SQL
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
#{table_name}
|
||||
WHERE
|
||||
(children->'registrant') @> '#{contact.id}'
|
||||
OR
|
||||
(children->'admin_contacts') @> '#{contact.id}'
|
||||
OR
|
||||
(children->'tech_contacts') @> '#{contact.id}'
|
||||
SQL
|
||||
|
||||
count_by_sql(sql).nonzero?
|
||||
end
|
||||
|
||||
def self.contact_unlinked_more_than?(contact:, period:)
|
||||
sql = <<-SQL
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
#{table_name}
|
||||
WHERE
|
||||
created_at < TIMESTAMP WITH TIME ZONE '#{period.ago}'
|
||||
AND (
|
||||
(children->'registrant') @> '#{contact.id}'
|
||||
OR
|
||||
(children->'admin_contacts') @> '#{contact.id}'
|
||||
OR
|
||||
(children->'tech_contacts') @> '#{contact.id}'
|
||||
)
|
||||
SQL
|
||||
|
||||
count_by_sql(sql).nonzero?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue