-
Notifications
You must be signed in to change notification settings - Fork 26
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
Show discrepancies in UI for ballot comparison audits #2034
Show discrepancies in UI for ballot comparison audits #2034
Conversation
b4fbcdd
to
3fa1594
Compare
53bfe52
to
f5fe503
Compare
1799cd5
to
2d10c12
Compare
f5fe503
to
7d1bfc7
Compare
f518012
to
f0a7b18
Compare
server/api/jurisdictions.py
Outdated
# It converts string numbers to int numbers, leaving non-numbers as is (i.e. 'o', 'u'). This is useful for | ||
# ballot CVRs to ensure that numbers are always returned as numbers, to match the behavior of batch discrepancies | ||
# and of vote deltas | ||
def normalize_vals_for_discrepancies( |
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.
Ballot comparison cvrs are different than their batch comparison equivalent in that the values are all strings vs ints, to support 'o' and 'u'. Though, the code did describe it as a somewhat special case, so I am not certain it is relevant and could use some validation.
In the case where it is relevant, I thought it would be better to be consistent in returning ints where it is a number, so that is the purpose of this function. It allows us to have a single return type for discrepancies that is relatively clear. Feel free to let me know if it doesn't seem right
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.
What happens if we just leave them as their internal representation (ints for batch comparison, strings for ballot comparison)? Might be simpler to just keep the same representation until there's somewhere we actually need to use the strings as ints, that way you don't need to think about whether it's an int in one place or a string in other places
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.
Hm that's true. I guess I thought it might be a bit odd if the frontend is getting strings on some API calls and ints on others for the same field values, when they might both be representing a 1, so that is what motivated me to normalize it. But, leaving them as is will work for sure too.
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.
Removed normalization here
f0a7b18
to
f8e662b
Compare
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.
Thanks for the explanatory comments!
server/api/jurisdictions.py
Outdated
( | ||
sampled_ballot_id, | ||
f"{tabulator}, {name}, Ballot Position {ballot_position}" | ||
+ (f", Container {container}" if container is not None else ""), |
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.
Container should go at the beginning, if present, and not in parens (it's the highest level in the hierarchy - i.e. multiple tabulators' batches could be in a container)
server/api/jurisdictions.py
Outdated
reported_votes = {} | ||
if reported_cvr and contest.id in reported_cvr: | ||
reported_votes = reported_cvr[contest.id] | ||
|
||
audited_votes = {} | ||
if audited_cvr and contest.id in audited_cvr: | ||
audited_votes = audited_cvr[contest.id] |
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 think reported_cvr
and audited_cvr
are guaranteed to be non-null at this point due to the checks in ballot_vote_deltas
, so these could probably be condensed to:
reported_votes = reported_cvr.get(contest.id, {})
audited_votes = audited_cvr.get(contest.id, {})
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.
Since the type of audited_cvr
and reported_cvr
is CVR which is an optional, it can be None. So, mypy complains that Item "None" of "Optional[Dict[str, Dict[str, str]]]" has no attribute "get"
. I think that is why I originally had that check.
Added the use of .get
, but left the null check here, unless there is a cleaner way to do this.
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 meant they are logically guaranteed to not be None. I know the type system can't figure that out, since the checks to handle the None cases are in a different function. Up to you whether you prefer handling an impossible case to satisfy the type-system or overriding with a type assertion (I usually go for the latter, but that's just my style). Totally fine to leave it as is
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.
Oh interesting. Thanks for the clarification and my bad for the miss there. I'll add in the type assertion. Still getting used to use to using type assertions consistently, but I see the benefit
server/api/jurisdictions.py
Outdated
# It converts string numbers to int numbers, leaving non-numbers as is (i.e. 'o', 'u'). This is useful for | ||
# ballot CVRs to ensure that numbers are always returned as numbers, to match the behavior of batch discrepancies | ||
# and of vote deltas | ||
def normalize_vals_for_discrepancies( |
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.
What happens if we just leave them as their internal representation (ints for batch comparison, strings for ballot comparison)? Might be simpler to just keep the same representation until there's somewhere we actually need to use the strings as ints, that way you don't need to think about whether it's an int in one place or a string in other places
client/src/components/AuditAdmin/Progress/JurisdictionDiscrepancies.tsx
Outdated
Show resolved
Hide resolved
case undefined: | ||
return 0 | ||
default: | ||
return val |
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.
Might be nice to add a .toLocaleString()
for longer numbers
client/src/components/AuditAdmin/Progress/JurisdictionDiscrepancies.tsx
Outdated
Show resolved
Hide resolved
bee8123
to
ca24e16
Compare
…mprove formatVoteCount
ca24e16
to
83946d1
Compare
Recommend to review commit by commit
This PR adds discrepancies in UI for ballot comparison audits.
Issue
Screen.Recording.2024-11-04.at.4.52.37.PM.mov