diff --git a/app/components/post_votes_tooltip_component.rb b/app/components/post_votes_tooltip_component.rb index 8408bcdb2..32abdad8a 100644 --- a/app/components/post_votes_tooltip_component.rb +++ b/app/components/post_votes_tooltip_component.rb @@ -19,9 +19,13 @@ class PostVotesTooltipComponent < ApplicationComponent vote.is_positive? ? upvote_icon : downvote_icon end + def vote_count + post.up_score + post.down_score.abs + end + def upvote_ratio - return nil if votes.length == 0 - sprintf("(%.1f%%)", 100.0 * post.up_score / (post.up_score + post.down_score.abs)) + return nil if vote_count == 0 + sprintf("(%.1f%%)", 100.0 * post.up_score / vote_count) end def voter_name(vote)