mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 22:44:11 +02:00
Add more logging detail
This commit is contained in:
parent
fbabd2029c
commit
27f2157765
2 changed files with 25 additions and 14 deletions
|
@ -885,20 +885,21 @@ Example: `cf ssh getgov-za`
|
||||||
[Follow these steps](#use-scp-to-transfer-data-to-sandboxes) to upload the federal_cio csv to a sandbox of your choice.
|
[Follow these steps](#use-scp-to-transfer-data-to-sandboxes) to upload the federal_cio csv to a sandbox of your choice.
|
||||||
|
|
||||||
#### Step 5: Running the script
|
#### Step 5: Running the script
|
||||||
```./manage.py create_federal_portfolio "{federal_agency_name}" --parse_requests --parse_domains```
|
```./manage.py create_federal_portfolio "{federal_agency_name}" --both```
|
||||||
|
|
||||||
Example: `./manage.py create_federal_portfolio "AMTRAK" --parse_requests --parse_domains`
|
Example: `./manage.py create_federal_portfolio "AMTRAK" --parse_requests --parse_domains`
|
||||||
|
|
||||||
### Running locally
|
### Running locally
|
||||||
|
|
||||||
#### Step 1: Running the script
|
#### Step 1: Running the script
|
||||||
```docker-compose exec app ./manage.py create_federal_portfolio "{federal_agency_name}" --parse_requests --parse_domains```
|
```docker-compose exec app ./manage.py create_federal_portfolio "{federal_agency_name}" --both```
|
||||||
|
|
||||||
##### Parameters
|
##### Parameters
|
||||||
| | Parameter | Description |
|
| | Parameter | Description |
|
||||||
|:-:|:-------------------------- |:-------------------------------------------------------------------------------------------|
|
|:-:|:-------------------------- |:-------------------------------------------------------------------------------------------|
|
||||||
| 1 | **federal_agency_name** | Name of the FederalAgency record surrounded by quotes. For instance,"AMTRAK". |
|
| 1 | **federal_agency_name** | Name of the FederalAgency record surrounded by quotes. For instance,"AMTRAK". |
|
||||||
| 2 | **parse_requests** | Optional. If True, then the created portfolio is added to all related DomainRequests. |
|
| 2 | **both** | Optional. If True, runs parse_requests and parse_domains |
|
||||||
| 3 | **parse_domains** | Optional. If True, then the created portfolio is added to all related Domains. |
|
| 3 | **parse_requests** | Optional. If True, then the created portfolio is added to all related DomainRequests. |
|
||||||
|
| 4 | **parse_domains** | Optional. If True, then the created portfolio is added to all related Domains. |
|
||||||
|
|
||||||
Note: While you can specify both at the same time, you must specify either --parse_requests or --parse_domains. You cannot run the script without defining one or the other.
|
Note: While you can specify both at the same time, you must specify either --parse_requests or --parse_domains. You cannot run the script without defining one or the other.
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Command(BaseCommand):
|
||||||
else:
|
else:
|
||||||
proceed = TerminalHelper.prompt_for_execution(
|
proceed = TerminalHelper.prompt_for_execution(
|
||||||
system_exit_on_terminate=False,
|
system_exit_on_terminate=False,
|
||||||
info_to_inspect=f"""
|
prompt_message=f"""
|
||||||
The given portfolio '{federal_agency.agency}' already exists in our DB.
|
The given portfolio '{federal_agency.agency}' already exists in our DB.
|
||||||
If you cancel, the rest of the script will still execute but this record will not update.
|
If you cancel, the rest of the script will still execute but this record will not update.
|
||||||
""",
|
""",
|
||||||
|
@ -124,9 +124,12 @@ class Command(BaseCommand):
|
||||||
org_names = set(valid_agencies.values_list("organization_name", flat=True))
|
org_names = set(valid_agencies.values_list("organization_name", flat=True))
|
||||||
|
|
||||||
if not org_names:
|
if not org_names:
|
||||||
TerminalHelper.colorful_logger(
|
message = (
|
||||||
logger.warning, TerminalColors.YELLOW, f"No suborganizations found for '{federal_agency}'"
|
"Could not add any suborganizations."
|
||||||
|
f"\nNo suborganizations were found for '{federal_agency}' when filtering on this name, "
|
||||||
|
"and excluding null organization_name records."
|
||||||
)
|
)
|
||||||
|
TerminalHelper.colorful_logger(logger.warning, TerminalColors.FAIL, message)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check if we need to update any existing suborgs first. This step is optional.
|
# Check if we need to update any existing suborgs first. This step is optional.
|
||||||
|
@ -144,7 +147,7 @@ class Command(BaseCommand):
|
||||||
# However, this isn't needed for now so we can skip it.
|
# However, this isn't needed for now so we can skip it.
|
||||||
message = (
|
message = (
|
||||||
f"Skipping suborganization create on record '{name}'. "
|
f"Skipping suborganization create on record '{name}'. "
|
||||||
f"The federal agency name is the same as the portfolio name."
|
"The federal agency name is the same as the portfolio name."
|
||||||
)
|
)
|
||||||
TerminalHelper.colorful_logger(logger.warning, TerminalColors.YELLOW, message)
|
TerminalHelper.colorful_logger(logger.warning, TerminalColors.YELLOW, message)
|
||||||
else:
|
else:
|
||||||
|
@ -165,7 +168,7 @@ class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
proceed = TerminalHelper.prompt_for_execution(
|
proceed = TerminalHelper.prompt_for_execution(
|
||||||
system_exit_on_terminate=False,
|
system_exit_on_terminate=False,
|
||||||
info_to_inspect=f"""Some suborganizations already exist in our DB.
|
prompt_message=f"""Some suborganizations already exist in our DB.
|
||||||
If you cancel, the rest of the script will still execute but these records will not update.
|
If you cancel, the rest of the script will still execute but these records will not update.
|
||||||
|
|
||||||
==Proposed Changes==
|
==Proposed Changes==
|
||||||
|
@ -178,7 +181,7 @@ class Command(BaseCommand):
|
||||||
org.portfolio = portfolio
|
org.portfolio = portfolio
|
||||||
|
|
||||||
Suborganization.objects.bulk_update(orgs_to_update, ["portfolio"])
|
Suborganization.objects.bulk_update(orgs_to_update, ["portfolio"])
|
||||||
message = f"Updated {len(orgs_to_update)} suborganizations"
|
message = f"Updated {len(orgs_to_update)} suborganizations."
|
||||||
TerminalHelper.colorful_logger(logger.info, TerminalColors.MAGENTA, message)
|
TerminalHelper.colorful_logger(logger.info, TerminalColors.MAGENTA, message)
|
||||||
|
|
||||||
def handle_portfolio_requests(self, portfolio: Portfolio, federal_agency: FederalAgency):
|
def handle_portfolio_requests(self, portfolio: Portfolio, federal_agency: FederalAgency):
|
||||||
|
@ -192,8 +195,12 @@ class Command(BaseCommand):
|
||||||
DomainRequest.DomainRequestStatus.REJECTED,
|
DomainRequest.DomainRequestStatus.REJECTED,
|
||||||
]
|
]
|
||||||
domain_requests = DomainRequest.objects.filter(federal_agency=federal_agency).exclude(status__in=invalid_states)
|
domain_requests = DomainRequest.objects.filter(federal_agency=federal_agency).exclude(status__in=invalid_states)
|
||||||
if not domain_requests.exists():
|
if domain_requests.exists():
|
||||||
message = "Portfolios not added to domain requests: no valid records found"
|
message = f"""
|
||||||
|
Portfolios not added to domain requests: no valid records found.
|
||||||
|
This means that a filter on DomainInformation for the federal_agency '{federal_agency}' returned no results.
|
||||||
|
Excluded statuses: STARTED, INELIGIBLE, REJECTED.
|
||||||
|
"""
|
||||||
TerminalHelper.colorful_logger(logger.info, TerminalColors.YELLOW, message)
|
TerminalHelper.colorful_logger(logger.info, TerminalColors.YELLOW, message)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -205,7 +212,7 @@ class Command(BaseCommand):
|
||||||
domain_request.sub_organization = suborgs.get(domain_request.organization_name)
|
domain_request.sub_organization = suborgs.get(domain_request.organization_name)
|
||||||
|
|
||||||
DomainRequest.objects.bulk_update(domain_requests, ["portfolio", "sub_organization"])
|
DomainRequest.objects.bulk_update(domain_requests, ["portfolio", "sub_organization"])
|
||||||
message = f"Added portfolio '{portfolio}' to {len(domain_requests)} domain requests"
|
message = f"Added portfolio '{portfolio}' to {len(domain_requests)} domain requests."
|
||||||
TerminalHelper.colorful_logger(logger.info, TerminalColors.OKGREEN, message)
|
TerminalHelper.colorful_logger(logger.info, TerminalColors.OKGREEN, message)
|
||||||
|
|
||||||
def handle_portfolio_domains(self, portfolio: Portfolio, federal_agency: FederalAgency):
|
def handle_portfolio_domains(self, portfolio: Portfolio, federal_agency: FederalAgency):
|
||||||
|
@ -215,7 +222,10 @@ class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
domain_infos = DomainInformation.objects.filter(federal_agency=federal_agency)
|
domain_infos = DomainInformation.objects.filter(federal_agency=federal_agency)
|
||||||
if not domain_infos.exists():
|
if not domain_infos.exists():
|
||||||
message = "Portfolios not added to domains: no valid records found"
|
message = f"""
|
||||||
|
Portfolios not added to domains: no valid records found.
|
||||||
|
This means that a filter on DomainInformation for the federal_agency '{federal_agency}' returned no results.
|
||||||
|
"""
|
||||||
TerminalHelper.colorful_logger(logger.info, TerminalColors.YELLOW, message)
|
TerminalHelper.colorful_logger(logger.info, TerminalColors.YELLOW, message)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue