votes: fix upvote ratio calculation.
Old posts don't have vote records, so we can't use vote records to calculate the ratio.
This commit is contained in:
@@ -21,7 +21,7 @@ class PostVotesTooltipComponent < ApplicationComponent
|
||||
|
||||
def upvote_ratio
|
||||
return nil if votes.length == 0
|
||||
sprintf("(%.1f%%)", 100.0 * votes.select(&:is_positive?).length / votes.length)
|
||||
sprintf("(%.1f%%)", 100.0 * post.up_score / (post.up_score + post.down_score.abs))
|
||||
end
|
||||
|
||||
def voter_name(vote)
|
||||
|
||||
Reference in New Issue
Block a user