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 3 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
32 changes: 21 additions & 11 deletions backend/census_historical_migration/workbooklib/findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,34 @@ def xform_sort_compliance_requirement(findings):


def xform_missing_compliance_requirement(findings):
"""Defaults missing compliance_requirement to GSA_MIGRATION."""
"""
Defaults missing compliance_requirement to GSA_MIGRATION.

We track all records related to a section that undergo transformation and
log these changes in 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 InspectionRecord.
"""
change_records = []
is_empty_compliance_requirement_found = False

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

if change_records and is_empty_compliance_requirement_found:
InspectionRecord.append_finding_changes(change_records)
Expand Down