Skip to content

Commit

Permalink
Only surface discrepancies in single jurisdiction for finalized batch…
Browse files Browse the repository at this point in the history
…es (#2095)

* Only surface discrepancies in single jurisdiction for finalized batches

* Update sampled_batch_results instead of using heuristic of non-empty audit result
  • Loading branch information
nikhilb4a authored Dec 16, 2024
1 parent 9c8ef4b commit 799f08e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/api/discrepancies.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def get_batch_comparison_discrepancies_by_jurisdiction(
.with_entities(Jurisdiction.name, Batch.name)
.all()
)

jurisdiction_name_to_id = dict(
Jurisdiction.query.filter_by(election_id=election.id).with_entities(
Jurisdiction.name, Jurisdiction.id
Expand Down
1 change: 1 addition & 0 deletions server/api/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def sampled_batch_results(
.filter(Contest.id == contest.id)
.join(ContestChoice)
.outerjoin(BatchResultTallySheet)
.filter(BatchResultTallySheet.batch_id.isnot(None))
.outerjoin(
BatchResult,
and_(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ def test_batch_comparison_single_jurisdiction_discrepancies(
choice_names = [choice["name"] for choice in contests[0]["choices"]]
choice_ids = [choice["id"] for choice in contests[0]["choices"]]

# No discrepancies should show before any batches are audited
set_logged_in_user(client, UserType.AUDIT_ADMIN, DEFAULT_AA_EMAIL)
rv = client.get(f"/api/election/{election_id}/discrepancy")
discrepancies = json.loads(rv.data)
assert len(discrepancies) == 0

# Audit batches
set_logged_in_user(
client, UserType.JURISDICTION_ADMIN, default_ja_email(election_id)
Expand Down

0 comments on commit 799f08e

Please sign in to comment.