Skip to content
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

Correcting TYPEREQUIREMENT transformation tracking #3825

Merged
merged 6 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions backend/census_historical_migration/workbooklib/findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@

logger = logging.getLogger(__name__)

# Transformation Method Change Recording
# For the purpose of recording changes, the transformation methods (i.e., xform_***)
# below track all records related to the federal_awards section that undergoes transformation and
# log these changes in a temporary array called `change_records`.
# However, we only save this data into the InspectionRecord table if at least one of the records has been
# modified by the transformation. If no records related to the given section
# were modified, then we do not save `change_records` into the InspectionRecord.


def xform_sort_compliance_requirement(findings):
"""Sorts and uppercases the compliance requirement string."""
Expand All @@ -40,18 +48,21 @@ def xform_missing_compliance_requirement(findings):
for finding in findings:
compliance_requirement = string_to_string(finding.TYPEREQUIREMENT)
if not compliance_requirement:
track_transformations(
"TYPEREQUIREMENT",
finding.TYPEREQUIREMENT,
"type_requirement",
settings.GSA_MIGRATION,
["xform_missing_compliance_requirement"],
change_records,
)

is_empty_compliance_requirement_found = True
finding.TYPEREQUIREMENT = settings.GSA_MIGRATION
compliance_requirement = settings.GSA_MIGRATION

track_transformations(
"TYPEREQUIREMENT",
finding.TYPEREQUIREMENT,
"type_requirement",
compliance_requirement,
["xform_missing_compliance_requirement"],
change_records,
)

finding.TYPEREQUIREMENT = compliance_requirement

# See Transformation Method Change Recording comment at the top of this file
if change_records and is_empty_compliance_requirement_found:
InspectionRecord.append_finding_changes(change_records)

Expand Down