From 22ace8aee9ed1c0732a0e3645c8e2ba0e450797f Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:23:05 -0800 Subject: [PATCH] Convert domain lists to counters --- .../commands/disclose_security_emails.py | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/registrar/management/commands/disclose_security_emails.py b/src/registrar/management/commands/disclose_security_emails.py index 339a34f9a..c7a202a2e 100644 --- a/src/registrar/management/commands/disclose_security_emails.py +++ b/src/registrar/management/commands/disclose_security_emails.py @@ -20,13 +20,13 @@ class Command(BaseCommand): """Sets global variables for code tidyness""" super().__init__() # domains and transition domains that must be disclosed to true - self.contacts_saved: list[str] = [] + self.contacts_saved_count = 0 # domains with errors, which are not successfully updated to disclose self.domains_with_errors: list[str] = [] # domains that are successfully disclosed - self.disclosed_domain_contacts: list[str] = [] + self.disclosed_domain_contacts_counter = 0 # domains that skip disclose due to having contact registrar@dotgov.gov - self.skipped_domain_contacts: list[str] = [] + self.skipped_domain_contacts_counter = 0 def handle(self, **options): """ @@ -45,33 +45,37 @@ class Command(BaseCommand): # Call security_contact on all domains to trigger saving contact information for domain in domains: contact = domain.security_contact - self.contacts_saved.append(copy.deepcopy(contact)) + self.contacts_saved_count++ - logger.info("Found %d security contacts.", len(self.contacts_saved)) + logger.info("Found %d security contacts.", self.contacts_saved) # Update EPP contact for domains with a security contact for domain in domains: try: - logger.info("Domain %s security contact: %s", domain.domain_info, domain.security_contact.email) + logger.info("Domain %s security contact: %s", domain.domain_name, domain.security_contact.email) if domain.security_contact.email != "registrar@dotgov.gov": domain._update_epp_contact(contact=domain.security_contact) - self.disclosed_domain_contacts.append(copy.deepcopy(domain.security_contact)) + self.disclosed_domain_contacts++ else: logger.info( "Skipping disclose for %s security contact %s.", - domain.domain_info, + domain.domain_name, domain.security_contact.email, ) - self.skipped_domain_contacts.append(copy.deepcopy(domain.security_contact)) + self.skipped_domain_contacts++ except Exception as err: # error condition if domain not in database self.domains_with_errors.append(copy.deepcopy(domain.domain_info)) logger.error(f"error retrieving domain {domain.domain_info}: {err}") # Inform user how many contacts were disclosed, skipped, and errored - logger.info("Updated %d contacts to disclosed.", len(self.disclosed_domain_contacts)) + logger.info("Updated %d contacts to disclosed.", self.disclosed_domain_contacts) logger.info( "Skipped disclosing %d contacts with security email registrar@dotgov.gov.", - len(self.skipped_domain_contacts) + self.skipped_domain_contacts ) - logger.info("Error disclosing %d contacts.", len(self.domains_with_errors)) \ No newline at end of file + logger.info( + "Error disclosing the following %d contacts: s", + len(self.domains_with_errors), + self.domains_with_errors + ) \ No newline at end of file