From aaa16842df9bab5c10dff3f6985511d8f61a29cf Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:44:52 -0700 Subject: [PATCH] Doc update --- docs/operations/data_migration.md | 22 ++++++++++++------- .../commands/create_federal_portfolio.py | 11 +++++++--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/operations/data_migration.md b/docs/operations/data_migration.md index a234d882b..0863aa0b7 100644 --- a/docs/operations/data_migration.md +++ b/docs/operations/data_migration.md @@ -893,22 +893,28 @@ 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. #### Step 5: Running the script -```./manage.py create_federal_portfolio "{federal_agency_name}" --both``` - +To create a specific portfolio: +```./manage.py create_federal_portfolio --agency_name "{federal_agency_name}" --both``` Example (only requests): `./manage.py create_federal_portfolio "AMTRAK" --parse_requests` +To create a portfolios for all federal agencies in a branch: +```./manage.py create_federal_portfolio --branch "{executive|legislative|judicial}" --both``` +Example (only requests): `./manage.py create_federal_portfolio --branch "executive" --parse_requests` + ### Running locally #### Step 1: Running the script -```docker-compose exec app ./manage.py create_federal_portfolio "{federal_agency_name}" --both``` +```docker-compose exec app ./manage.py create_federal_portfolio --agency_name "{federal_agency_name}" --both``` ##### Parameters | | Parameter | Description | |:-:|:-------------------------- |:-------------------------------------------------------------------------------------------| -| 1 | **federal_agency_name** | Name of the FederalAgency record surrounded by quotes. For instance,"AMTRAK". | -| 2 | **both** | If True, runs parse_requests and parse_domains. | -| 3 | **parse_requests** | If True, then the created portfolio is added to all related DomainRequests. | -| 4 | **parse_domains** | If True, then the created portfolio is added to all related Domains. | +| 1 | **agency_name** | Name of the FederalAgency record surrounded by quotes. For instance,"AMTRAK". | +| 2 | **branch** | Creates a portfolio for each federal agency in a branch: executive, legislative, judicial | +| 3 | **both** | If True, runs parse_requests and parse_domains. | +| 4 | **parse_requests** | If True, then the created portfolio is added to all related DomainRequests. | +| 5 | **parse_domains** | If True, then the created portfolio is added to all related Domains. | -Note: Regarding parameters #2-#3, you cannot use `--both` while using these. You must specify either `--parse_requests` or `--parse_domains` seperately. While all of these parameters are optional in that you do not need to specify all of them, +- Parameters #1-#2: Either `--agency_name` or `--branch` must be specified. Not both. +- Parameters #2-#3, you cannot use `--both` while using these. You must specify either `--parse_requests` or `--parse_domains` seperately. While all of these parameters are optional in that you do not need to specify all of them, you must specify at least one to run this script. diff --git a/src/registrar/management/commands/create_federal_portfolio.py b/src/registrar/management/commands/create_federal_portfolio.py index 4c0856fb4..48202a93b 100644 --- a/src/registrar/management/commands/create_federal_portfolio.py +++ b/src/registrar/management/commands/create_federal_portfolio.py @@ -14,6 +14,7 @@ class Command(BaseCommand): help = "Creates a federal portfolio given a FederalAgency name" def __init__(self, *args, **kwargs): + """Defines fields to track what portfolios were updated, skipped, or just outright failed.""" super().__init__(*args, **kwargs) self.updated_portfolios = set() self.skipped_portfolios = set() @@ -209,8 +210,11 @@ class Command(BaseCommand): if not domain_requests.exists(): message = f""" Portfolio '{portfolio}' not added to domain requests: no valid records found. - This means that a filter on DomainInformation for the federal_agency '{federal_agency}' and portfolio__isnull=True returned no results. + This means that a filter on DomainInformation for the federal_agency '{federal_agency}' returned no results. Excluded statuses: STARTED, INELIGIBLE, REJECTED. + Filter info: DomainRequest.objects.filter(federal_agency=federal_agency, portfolio__isnull=True).exclude( + status__in=invalid_states + ) """ TerminalHelper.colorful_logger(logger.info, TerminalColors.YELLOW, message) return None @@ -236,7 +240,8 @@ class Command(BaseCommand): if not domain_infos.exists(): message = f""" Portfolio '{portfolio}' not added to domains: no valid records found. - The filter on DomainInformation for the federal_agency '{federal_agency}' and portfolio__isnull=True returned no results. + The filter on DomainInformation for the federal_agency '{federal_agency}' returned no results. + Filter info: DomainInformation.objects.filter(federal_agency=federal_agency, portfolio__isnull=True) """ TerminalHelper.colorful_logger(logger.info, TerminalColors.YELLOW, message) return None @@ -249,5 +254,5 @@ class Command(BaseCommand): domain_info.sub_organization = suborgs.get(domain_info.organization_name) DomainInformation.objects.bulk_update(domain_infos, ["portfolio", "sub_organization"]) - message = f"Added portfolio '{portfolio}' to {len(domain_infos)} domains" + message = f"Added portfolio '{portfolio}' to {len(domain_infos)} domains." TerminalHelper.colorful_logger(logger.info, TerminalColors.OKGREEN, message)