Refactor web and booth votes calculations
This commit is contained in:
@@ -22,20 +22,16 @@ class Poll::Stats
|
|||||||
total_participants_web + total_participants_booth
|
total_participants_web + total_participants_booth
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_participants_web
|
%i[web booth].each do |channel|
|
||||||
total_web_valid + total_web_white + total_web_null
|
define_method :"total_participants_#{channel}" do
|
||||||
end
|
send(:"total_#{channel}_valid") +
|
||||||
|
send(:"total_#{channel}_white") +
|
||||||
|
send(:"total_#{channel}_null")
|
||||||
|
end
|
||||||
|
|
||||||
def total_participants_web_percentage
|
define_method :"total_participants_#{channel}_percentage" do
|
||||||
calculate_percentage(total_participants_web, total_participants)
|
calculate_percentage(send(:"total_participants_#{channel}"), total_participants)
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_participants_booth
|
|
||||||
total_booth_valid + total_booth_white + total_booth_null
|
|
||||||
end
|
|
||||||
|
|
||||||
def total_participants_booth_percentage
|
|
||||||
calculate_percentage(total_participants_booth, total_participants)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_web_valid
|
def total_web_valid
|
||||||
|
|||||||
Reference in New Issue
Block a user