From a5b0b289e01af842d9c32622e347f82a525f3170 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Mon, 17 Jan 2022 17:26:01 +0300 Subject: [PATCH] Refactoring --- app/models/validation_event.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/validation_event.rb b/app/models/validation_event.rb index 6af2daa2f..7585eb676 100644 --- a/app/models/validation_event.rb +++ b/app/models/validation_event.rb @@ -73,13 +73,8 @@ class ValidationEvent < ApplicationRecord def refresh_status_notes old_email = object.email_history - domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten - registrant_ids = Registrant.where(email: email).pluck(:id) - domains = domain_contacts.map(&:domain).flatten + - Domain.where(registrant_id: registrant_ids) - - domains.uniq.each do |domain| + domain_list.uniq.each do |domain| next unless domain.status_notes[DomainStatus::FORCE_DELETE] domain.status_notes[DomainStatus::FORCE_DELETE].slice!(old_email) @@ -90,6 +85,13 @@ class ValidationEvent < ApplicationRecord end end + def domain_list + domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten + registrant_ids = Registrant.where(email: email).pluck(:id) + + domain_contacts.map(&:domain).flatten + Domain.where(registrant_id: registrant_ids) + end + def notify_registrar(domain) domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email', domain_name: domain.name,