gearheads
/
mastodon
Archived
2
0
Fork 0

Clear voter count when poll is reset (#21700)

When a poll is edited, we reset the poll and remove all previous
votes. However, prior to this commit, the voter count on the poll
was not reset. This leads to incorrect percentages being shown in
poll results.

Fixes #21696
gh/stable
afontenot 2022-11-26 14:08:25 -08:00 committed by GitHub
parent 95b24c51ec
commit f17fc5742e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -85,6 +85,7 @@ class Poll < ApplicationRecord
def reset_votes! def reset_votes!
self.cached_tallies = options.map { 0 } self.cached_tallies = options.map { 0 }
self.votes_count = 0 self.votes_count = 0
self.voters_count = 0
votes.delete_all unless new_record? votes.delete_all unless new_record?
end end