aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalen Guyer <galen@galenguyer.com>2022-08-11 14:50:07 -0400
committerGalen Guyer <galen@galenguyer.com>2022-08-11 14:50:07 -0400
commita96968f0c620b7070817883f88bee88febe6f69a (patch)
tree3c72f721e6b5d3678c3a182487bdec206cc6ca7f
parent0d48dffe8eb258a8b0528e6fbdc9bf94ffbbd4e9 (diff)
Show options that got no votes
-rw-r--r--README.md3
-rw-r--r--database/poll.go5
2 files changed, 6 insertions, 2 deletions
diff --git a/README.md b/README.md
index 73a3356..1e00034 100644
--- a/README.md
+++ b/README.md
@@ -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
}