-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
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.
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) => { |
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.
The linter doesn't complain? I thought you'd have to write .map(([_, totalCount]
here.
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.
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, |
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.
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.
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.
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][] = []; |
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.
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.
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, | ||
]); |
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.
Or remove the let result
altogether and do something like:
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" |
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.
Joke: Wir haben keine Übersetzung dafür? Sowas... "CMGS"?
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.
https://www.din.de/de/wdc-beuth:din21:5463877
jedenfalls nicht in Deutschland 🤷♀️
Display election results as total count instead of percent and order by count. Adds tests for the results.
Closes #45