Skip to content

Adding inital data comparison#5206

Draft
jadudm wants to merge 37 commits into
mainfrom
compare-submissions
Draft

Adding inital data comparison#5206
jadudm wants to merge 37 commits into
mainfrom
compare-submissions

Conversation

@jadudm
Copy link
Copy Markdown
Contributor

@jadudm jadudm commented Aug 20, 2025

From ticket: #5199

problem

We want to provide an initial/v1 overview of "what changed?" between two audits in a resubmission. We want to do this in two places:

  1. For submitters, so they can see what changed before they lock and certfiy. (Perhaps after crossval? 🤷 )
  2. For oversight officials, to see differences between the current and previous audit in a chain.
image

solution

This PR introduces:

  1. Code that will compare two SAC rows (because we are potentially dealing with audits that have not been submitted as well as audits that are submitted)
  2. Code that provides a view we can use in two places.
  3. The modification to the checklist for submitters so they can use this when resubmitting.

screen grabs


New checklist item

When a resubmission is active, there is a new element to the resubmission checklist.

image

Comparison page

This is a representative comparison page.

image

testing

To test manually:

  1. create resubmissions manually
  2. click the new compare checklist item to review changes
  3. make sure to test a resubmission of a resubmission!!
  4. also test a resubmission that does not actually change
  5. to view a comparison in any condition, visit directly http://localhost:8000/audit/compare/<report_id>

Not linted, but it is tested.

Want to get other people's eyes on it.
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 20, 2025

Terraform plan for meta

No changes. Your infrastructure matches the configuration.
No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

📝 Plan generated in Pull Request Checks #651

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 20, 2025

Terraform plan for dev

Plan: 1 to add, 0 to change, 1 to destroy.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.dev.module.cors.null_resource.cors_header must be replaced
-/+ resource "null_resource" "cors_header" {
!~      id       = "*******************" -> (known after apply)
!~      triggers = { # forces replacement
!~          "always_run" = "2026-03-27T12:43:52Z" -> (known after apply)
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.

📝 Plan generated in Pull Request Checks #651

Visit

http://localhost:8000/audit/compare/2023-12-GSAFAC-0000058119/2023-12-GSAFAC-0000065436

to see a pair of audits compared. These are a "resubmission."

For two that are very different:

http://localhost:8000/audit/compare/2023-12-GSAFAC-0000058119/2023-09-GSAFAC-0000016690

This assumes *full* data loaded. No need to truncate.
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

Adding more info to what comes back, so that we can present it better.

More consistent across categories of difference, for ease of rendering.

Improved layout.
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

This would be what it looks like if we only show what changed.

The page gets much shorter. And, perhaps, more understandable, because
we are not showing things that did not change. Less to parse.
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

More tests.

The "compare_with_previous" code can serve as test code for resubmission
generation, in a way.

This fixes how we initiate a resubmission. It eliminates most data being
copied over. We should largely end up with an empty audit, save for some
metadata.

Correctly yields differences.
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

Not sure where it happens.

However, it cannot be allowed to happen.

When we do a resub, it cannot modify the original.
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

- add url pattern for resub comparison page(s)
- fix sac comparison logic and tests
diff --git a/backend/audit/test_viewlib/test_compare_submissions.py b/backend/audit/test_viewlib/test_compare_submissions.py
index 8dba783..5aceaec 100644
--- a/backend/audit/test_viewlib/test_compare_submissions.py
+++ b/backend/audit/test_viewlib/test_compare_submissions.py
@@ -1,4 +1,3 @@
-import unittest
 from django.test import TestCase
 from audit.viewlib.compare_two_submissions import (
     compare_report_ids,
@@ -372,8 +371,6 @@ class CompareSubmissionTests(TestCase):

         res = compare_lists_of_objects(d1, d2, ["b"], lambda o: o["value"])

-        print(f"res --> {res}")
-
         self.assertEqual(
             # res, {"status": "changed", "in_r1": ["2"], "in_r2": ["3"], "in_both": []}
             # res, {'status': 'changed', 'in_r1': [{'from': None, 'to': 2, 'key': 'b'}], 'in_r2': [{'from': None, 'to': 3, 'key': 'b'}], 'in_both': [{'from': 'Related to: name, value', 'to': '2 difference', 'key': 2}]}
@@ -390,7 +387,6 @@ class CompareSubmissionTests(TestCase):
         )

         res = compare_lists_of_objects(d1, d3, ["b"], lambda o: o["value"])
-        print(f"res --> {res}")

         self.assertEqual(
             # res, {"status": "changed", "in_r1": [], "in_r2": ["4"], "in_both": ["2"]}
diff --git a/backend/audit/viewlib/compare_two_submissions.py b/backend/audit/viewlib/compare_two_submissions.py
index 6186b7d..6fb6d2b 100644
--- a/backend/audit/viewlib/compare_two_submissions.py
+++ b/backend/audit/viewlib/compare_two_submissions.py
@@ -2,7 +2,6 @@ from audit.models import SingleAuditChecklist, SingleAuditReportFile
 from copy import deepcopy
 import logging
 import boto3
-import itertools
 from io import BytesIO
 from botocore.exceptions import ClientError
 from django.conf import settings
@phildominguez-gsa
Copy link
Copy Markdown
Contributor

phildominguez-gsa commented May 12, 2026

When a resubmission has no actual changes, it just has the Changes in Single Audit Report header. Can we remove that and put a blurb that mentions no changes were found?

image

Edit: Oh actually that blurb is commented out here. There is also a There are no changes between Single Audit Reports that doesn't seem to trigger.

</div>
<div>

<p class="text-bold margin-0">Check what changed in this resubmission</p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about linkifying this instead of in the sentence below? It would better match the format of the steps that follow it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and linkify the old report_id below this, too

<div class="grid-row">
<div class="tablet:grid-col">
<h1>Resubmission comparison</h1>
<p>To assist auditees and auditors in completing the resubmission of audits, the Clearinghouse provides an automated comparison between {{ r1 }} and {{ r2 }}.</p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaning towards making it more clear which one is the current one, and which one is the resub. Something like:

Suggested change
<p>To assist auditees and auditors in completing the resubmission of audits, the Clearinghouse provides an automated comparison between {{ r1 }} and {{ r2 }}.</p>
<p>To assist auditees and auditors in completing the resubmission of audits, the Clearinghouse provides an automated comparison between the previous submission ({{ r1 }}) and current submission ({{ r2 }}).</p>

and linkify the old report_id.

</div>
<div>

<p class="text-bold margin-0">Check what changed in this resubmission</p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and linkify the old report_id below this, too

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a thought. When initiating a resub you have to click the checkboxes that explain why a resub needs to be done. Should we display that on this page so they can better confirm the comparison results? Idt there's a means for them to even go back and see what they had selected. Heck, maybe even have the checkboxes here in case they want to change it? All this can be done in a later ticket, though.

<caption>Changes only in {{ r1 }}</caption>
<thead>
<tr>
<th scope="col">Element</th>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with "Field"

Comment on lines +38 to +39
<th scope="col">{{ r1 | slice:"15:" }}</th>
<th scope="col">{{ r2 | slice:"15:" }}</th>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might prefer "old value" and "new value" but I'm curious what others think

{% if changed.in_r1|length > 0 %}
<div class="grid-row">
<div class="tablet:grid-col">
<table class="usa-table width-full">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to include the cell from the spreadsheet that these values are pulling from? Could be useful for them but I'm not sure how readily accessible it is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we're gonna need something more layman-friendly when it comes to the PDF diff. Chances are they won't know what a sha256 is. Maybe instead of a table we just write out "We've detected changes between the Single Audit Reports" etc and mention the different character lengths? We could include a link to the old PDF too.

@daryll daryll deployed to testing May 14, 2026 15:51 — with GitHub Actions Active
@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Branch Rate Health
. 100% 100%
api 98% 86%
api.serializers 97% 88%
api.views 91% 96%
audit 95% 80%
audit.cross_validation 97% 86%
audit.fixtures 84% 50%
audit.formlib 92% 62%
audit.intakelib 89% 83%
audit.intakelib.checks 92% 86%
audit.intakelib.common 98% 82%
audit.intakelib.transforms 100% 95%
audit.management.commands 78% 17%
audit.migrations 100% 100%
audit.models 91% 69%
audit.templatetags 95% 100%
audit.test_viewlib 99% 88%
audit.viewlib 82% 78%
audit.views 76% 54%
census_historical_migration 96% 65%
census_historical_migration.migrations 100% 100%
census_historical_migration.sac_general_lib 92% 84%
census_historical_migration.transforms 95% 90%
census_historical_migration.workbooklib 68% 69%
config 78% 37%
curation 94% 86%
curation.curationlib 91% 71%
curation.management.commands 46% 34%
curation.migrations 100% 100%
dissemination 90% 70%
dissemination.analytics 27% 0%
dissemination.forms 80% 30%
dissemination.migrations 97% 25%
dissemination.models 100% 100%
dissemination.report_generation 21% 0%
dissemination.report_generation.excel 32% 0%
dissemination.searchlib 61% 44%
dissemination.templatetags 52% 6%
dissemination.views 67% 47%
djangooidc 53% 38%
djangooidc.tests 100% 94%
report_submission 100% 96%
report_submission.migrations 100% 100%
report_submission.templatetags 74% 100%
report_submission.views 78% 61%
support 94% 75%
support.migrations 100% 100%
support.models 90% 50%
tools 98% 50%
users 95% 86%
users.fixtures 100% 83%
users.management 100% 100%
users.management.commands 100% 100%
users.migrations 100% 100%
Summary 88% (22934 / 25930) 69% (2844 / 4124)

Minimum allowed line rate is 85%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants