diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-08-11 14:50:07 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2022-08-11 14:50:07 -0400 |
commit | a96968f0c620b7070817883f88bee88febe6f69a (patch) | |
tree | 3c72f721e6b5d3678c3a182487bdec206cc6ca7f | |
parent | 0d48dffe8eb258a8b0528e6fbdc9bf94ffbbd4e9 (diff) |
Show options that got no votes
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | database/poll.go | 5 |
2 files changed, 6 insertions, 2 deletions
@@ -23,7 +23,6 @@ VOTE_STATE= - [x] Custom vote options - [x] Write-in votes - [x] Ranked choice voting -- [ ] Show options that got no votes -- [ ] Write-In Fuzzy Matching +- [x] Show options that got no votes - [ ] Allow results to be hidden until a vote is closed - [ ] Don't let the user fuck it up diff --git a/database/poll.go b/database/poll.go index 1141d86..ab0f21c 100644 --- a/database/poll.go +++ b/database/poll.go @@ -170,6 +170,11 @@ func (poll *Poll) GetResult() (map[string]int, error) { var results []SimpleResult cursor.All(ctx, &results) + // Start by setting all the results to zero + for _, opt := range poll.Options { + finalResult[opt] = 0 + } + // Overwrite those with given votes and add write-ins for _, r := range results { finalResult[r.Option] = r.Count } |