Add Partial Results counts to question answers

This commit is contained in:
Bertocq
2017-10-23 23:51:55 +02:00
committed by Javi Martín
parent ba9346162c
commit f4260788eb
2 changed files with 3 additions and 2 deletions

View File

@@ -32,7 +32,8 @@ class Poll::Question::Answer < ApplicationRecord
end
def total_votes
Poll::Answer.where(question_id: question, answer: title).count
Poll::Answer.where(question_id: question, answer: title).count +
::Poll::PartialResult.where(question: question).where(answer: title).sum(:amount)
end
def most_voted?