mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FIX: closed polls with no votes showed NaN as percentage and average
This commit is contained in:
@ -7,7 +7,7 @@ export default Em.Component.extend({
|
||||
backgroundColor = this.get("poll.background");
|
||||
|
||||
this.get("poll.options").forEach(option => {
|
||||
const percentage = Math.floor(100 * option.get("votes") / totalVotes),
|
||||
const percentage = totalVotes == 0 ? 0 : Math.floor(100 * option.get("votes") / totalVotes),
|
||||
styles = ["width: " + percentage + "%"];
|
||||
|
||||
if (backgroundColor) { styles.push("background: " + backgroundColor); }
|
||||
|
Reference in New Issue
Block a user