-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3299: Script to update suborg values - [ZA] #3322
base: main
Are you sure you want to change the base?
Conversation
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
proceed_execution = TerminalHelper.query_yes_no_exit( | ||
f"""{TerminalColors.OKCYAN} | ||
===================================================== | ||
{prompt_title} | ||
===================================================== | ||
{verify_message} | ||
|
||
{prompt_message} | ||
{TerminalColors.FAIL} | ||
Proceed? (Y = proceed, N = {action_description_for_selecting_no}) | ||
{TerminalColors.ENDC}""" | ||
f"\n{TerminalColors.OKCYAN}" | ||
"=====================================================" | ||
f"\n{prompt_title}\n" | ||
"=====================================================" | ||
f"\n{verify_message}\n" | ||
f"\n{prompt_message}\n" | ||
f"{TerminalColors.FAIL}" | ||
f"Proceed? (Y = proceed, N = {action_description_for_selecting_no})" | ||
f"{TerminalColors.ENDC}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the spacing issue that has been present on this helper function, so now it is "left aligned" (in a sense)
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
This reverts commit bf9824a.
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
def handle_populate_portfolio(self, federal_agency, parse_domains, parse_requests, both): | ||
"""Attempts to create a portfolio. If successful, this function will | ||
also create new suborganizations""" | ||
portfolio, created = self.create_portfolio(federal_agency) | ||
if created: | ||
self.create_suborganizations(portfolio, federal_agency) | ||
if parse_domains or both: | ||
self.handle_portfolio_domains(portfolio, federal_agency) | ||
def handle_all_populate_portfolio(self, agencies, parse_domains, parse_requests, both): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just uncurling this logic into one function since we need to track all added suborgs, domains, and requests anyway. Ideally I'd put this in "handle" but we can't due to a C901 linter error. In any event, I think less function nesting is good.
Observation: I think its fine for now, but this script may need to be reorganized in the future as it continues to grow. Its grown in complexity since it was initially written
🥳 Successfully deployed to developer sandbox za. |
1 similar comment
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
🥳 Successfully deployed to developer sandbox za. |
if parse_domains or both: | ||
self.handle_portfolio_domains(portfolio, federal_agency) | ||
also create new suborganizations""" | ||
portfolio, _ = self.create_portfolio(federal_agency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the comment Returns the portfolio for the given federal_agency
removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! I just removed that because this function doesn't actually return anything - so I think it was a typo
class Command(BaseCommand): | ||
help = "Clean up duplicate suborganizations that differ only by spaces and capitalization" | ||
|
||
def handle(self, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the us of help text here!
normalize_string("USDA/OC"): {"replace_with": "USDA, Office of Communications"}, | ||
normalize_string("GSA, IC, OGP WebPortfolio"): {"replace_with": "GSA, IC, OGP Web Portfolio"}, | ||
normalize_string("USDA/ARS/NAL"): {"replace_with": "USDA, ARS, NAL"}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious as to where these values came from? Are they supposed to be hardcorded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They come from this spreadsheet. The create_federal_portfolio script assumes that the org names the user provides are always correct, but some domains misspelt their org name. Since its just a misspelling, these corner cases are hard coded. Data cleanup basically
Ticket
Resolves #3299
Changes
city
, andstate_territory
to the suborganizationspatch_suborganizations
which deletes duplicate suborg values (extra spaces in the name or weird capitalization) and replaces them with the "correct" suborg.normalize_string
andcount_capitals
Context for reviewers
When we ran the create_federal_portfolio script, it did not do a name normalize stop for federal_agency.agency. This meant that we had some duplicate records of the same name, that only differed by stray whitespace at the beginning of the string. Additionally, some user inputted data was determined to be incorrect. This script corrects those records, and also fixes the original create_federal_agency script to add city and state_territory information to the suborg as well.
Setup
This script needs a cloned db of staging to test fully. You will need to verify that (at least a few of) the records outlined in this spreadsheet are fixed. Additionally, you will need to verify that on suborganizations - the "city" and "state_territory" fields exist.
I've ran the updated script on za, so feel free to prod around the data to verify that everything is working. Once you are done with that, if you would like to run the script, I will reset the za db back to staging so you can verify that functionality.
When running the script, you should expect to see 13 delete suborgs.
Code Review Verification Steps
As the original developer, I have
Satisfied acceptance criteria and met development standards
Ensured code standards are met (Original Developer)
Validated user-facing changes (if applicable)
As a code reviewer, I have
Reviewed, tested, and left feedback about the changes
Validated user-facing changes as a developer
Note: Multiple code reviewers can share the checklists above, a second reviewer should not make a duplicate checklist. All checks should be checked before approving, even those labeled N/A.
As a designer reviewer, I have
Verified that the changes match the design intention
Validated user-facing changes as a designer
References
Screenshots