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

Display total count instead of percent and order by count #123

Merged
merged 6 commits into from
Feb 26, 2024
Merged

Conversation

PascalinDe
Copy link
Member

@PascalinDe PascalinDe commented Feb 23, 2024

Display election results as total count instead of percent and order by count. Adds tests for the results.

Closes #45

@PascalinDe PascalinDe requested a review from ineiti February 23, 2024 16:56
@PascalinDe PascalinDe self-assigned this Feb 23, 2024
Copy link
Member

@ineiti ineiti left a comment

Choose a reason for hiding this comment

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

Some comments, but nothing bad. As we're getting to the end of it, I'm also OK if you ignore my comments.

return { Candidate: select.Choices[index], Percentage: `${percent}%` };
});
res = countSelectResult(selectResult.get(id))
.map(([, totalCount], index) => {
Copy link
Member

Choose a reason for hiding this comment

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

The linter doesn't complain? I thought you'd have to write .map(([_, totalCount] here.

Copy link
Member Author

Choose a reason for hiding this comment

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

no, the linter is quite happy like that and actually made me change it to this 🤷‍♀️

return {
Candidate: select.Choices[index],
TotalCount: totalCount,
NumberOfBallots: selectResult.get(id).length,
Copy link
Member

Choose a reason for hiding this comment

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

Question: what is NumberOfBallots here?

  • the total ballots cast (including multi ballot cast)
  • the total number of voters (with multi ballot cast removed)
  • the total number of valid ballots (with multi ballot and invalid ballots removed)

I think both 2 and 3 are OK, but it should be mentioned somewhere on the page which it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

it's the number of valid ballots for the 'select' type of form as send back by the server

max = current;
}
return current;
let results: [string, number][] = [];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let results: [string, number][] = [];
const results: [string, number][] = [];

push and pop are allowed on const. But this makes sure that you don't re-assign it a different array.

Comment on lines +47 to +56
selectResult
.reduce(
(tally, currBallot) => tally.map((currCount, index) => currCount + currBallot[index]),
new Array(selectResult[0].length).fill(0)
)
.forEach((totalCount) => {
results.push([
(Math.round((totalCount / selectResult.length) * 100 * 100) / 100).toFixed(2).toString(),
totalCount,
]);
Copy link
Member

Choose a reason for hiding this comment

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

Or remove the let result altogether and do something like:

Suggested change
selectResult
.reduce(
(tally, currBallot) => tally.map((currCount, index) => currCount + currBallot[index]),
new Array(selectResult[0].length).fill(0)
)
.forEach((totalCount) => {
results.push([
(Math.round((totalCount / selectResult.length) * 100 * 100) / 100).toFixed(2).toString(),
totalCount,
]);
return selectResult
.reduce(
(tally, currBallot) => tally.map((currCount, index) => currCount + currBallot[index]),
new Array(selectResult[0].length).fill(0)
)
.map((totalCount) =>
[
(Math.round((totalCount / selectResult.length) * 100 * 100) / 100).toFixed(2).toString(),
totalCount,
]);

"Title": {
"En": "CMYK",
"Fr": "CMJN",
"De": "CMYK"
Copy link
Member

Choose a reason for hiding this comment

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

Joke: Wir haben keine Übersetzung dafür? Sowas... "CMGS"?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://www.din.de/de/wdc-beuth:din21:5463877

jedenfalls nicht in Deutschland 🤷‍♀️

@PascalinDe PascalinDe merged commit c819e31 into main Feb 26, 2024
11 checks passed
@PascalinDe PascalinDe deleted the 45 branch February 26, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

Results of a votation
2 participants