Display only poll stats for used channels

So if there's no vote using by mail (which is the case in some places),
no stats related to voting via mail are displayed.
This commit is contained in:
Javi Martín
2019-03-18 19:43:44 +01:00
parent 4843959c7d
commit 6b0b9db969
3 changed files with 57 additions and 7 deletions

View File

@@ -21,6 +21,10 @@ class Poll::Stats
total_participants_web + total_participants_booth
end
def channels
CHANNELS.select { |channel| send(:"total_participants_#{channel}") > 0 }
end
CHANNELS.each do |channel|
define_method :"total_participants_#{channel}" do
send(:"total_#{channel}_valid") +
@@ -58,7 +62,7 @@ class Poll::Stats
end
def total_letter_valid
0 # TODO
voters.where(origin: "letter").count # TODO: count only valid votes
end
def total_letter_white