gitlabhq/app/roles/votes.rb
Riyad Preukschas 7b0c7ae52c Add votes_count
2012-09-08 16:05:48 +02:00

17 lines
310 B
Ruby

module Votes
# Return the number of +1 comments (upvotes)
def upvotes
notes.select(&:upvote?).size
end
# Return the number of -1 comments (downvotes)
def downvotes
notes.select(&:downvote?).size
end
# Return the total number of votes
def votes_count
upvotes + downvotes
end
end