Add mail votes stub to poll stats
So far we don't know about implemenation details.
This commit is contained in:
@@ -2,22 +2,26 @@ class Poll::Stats
|
|||||||
include Statisticable
|
include Statisticable
|
||||||
alias_method :poll, :resource
|
alias_method :poll, :resource
|
||||||
|
|
||||||
|
CHANNELS = %i[web booth mail]
|
||||||
|
|
||||||
def self.stats_methods
|
def self.stats_methods
|
||||||
super +
|
super +
|
||||||
%i[total_valid_votes total_white_votes total_null_votes
|
%i[total_valid_votes total_white_votes total_null_votes
|
||||||
total_participants_web total_web_valid total_web_white total_web_null
|
total_participants_web total_web_valid total_web_white total_web_null
|
||||||
total_participants_booth total_booth_valid total_booth_white total_booth_null
|
total_participants_booth total_booth_valid total_booth_white total_booth_null
|
||||||
|
total_participants_mail total_mail_valid total_mail_white total_mail_null
|
||||||
total_participants_web_percentage total_participants_booth_percentage
|
total_participants_web_percentage total_participants_booth_percentage
|
||||||
valid_percentage_web valid_percentage_booth total_valid_percentage
|
total_participants_mail_percentage
|
||||||
white_percentage_web white_percentage_booth total_white_percentage
|
valid_percentage_web valid_percentage_booth valid_percentage_mail total_valid_percentage
|
||||||
null_percentage_web null_percentage_booth total_null_percentage]
|
white_percentage_web white_percentage_booth white_percentage_mail total_white_percentage
|
||||||
|
null_percentage_web null_percentage_booth null_percentage_mail total_null_percentage]
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_participants
|
def total_participants
|
||||||
total_participants_web + total_participants_booth
|
total_participants_web + total_participants_booth
|
||||||
end
|
end
|
||||||
|
|
||||||
%i[web booth].each do |channel|
|
CHANNELS.each do |channel|
|
||||||
define_method :"total_participants_#{channel}" do
|
define_method :"total_participants_#{channel}" do
|
||||||
send(:"total_#{channel}_valid") +
|
send(:"total_#{channel}_valid") +
|
||||||
send(:"total_#{channel}_white") +
|
send(:"total_#{channel}_white") +
|
||||||
@@ -53,8 +57,20 @@ class Poll::Stats
|
|||||||
recounts.sum(:null_amount)
|
recounts.sum(:null_amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def total_mail_valid
|
||||||
|
0 # TODO
|
||||||
|
end
|
||||||
|
|
||||||
|
def total_mail_white
|
||||||
|
0 # TODO
|
||||||
|
end
|
||||||
|
|
||||||
|
def total_mail_null
|
||||||
|
0 # TODO
|
||||||
|
end
|
||||||
|
|
||||||
%i[valid white null].each do |type|
|
%i[valid white null].each do |type|
|
||||||
%i[web booth].each do |channel|
|
CHANNELS.each do |channel|
|
||||||
define_method :"#{type}_percentage_#{channel}" do
|
define_method :"#{type}_percentage_#{channel}" do
|
||||||
calculate_percentage(send(:"total_#{channel}_#{type}"), send(:"total_#{type}_votes"))
|
calculate_percentage(send(:"total_#{channel}_#{type}"), send(:"total_#{type}_votes"))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,51 +30,53 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col"><%= t("polls.show.stats.votes") %></th>
|
<th scope="col"><%= t("polls.show.stats.votes") %></th>
|
||||||
<th scope="col"><%= t("polls.show.stats.web") %></th>
|
<% Poll::Stats::CHANNELS.each do |channel| %>
|
||||||
<th scope="col"><%= t("polls.show.stats.booth") %></th>
|
<th scope="col"><%= t("polls.show.stats.#{channel}") %></th>
|
||||||
|
<% end %>
|
||||||
<th scope="col"><%= t("polls.show.stats.total") %></th>
|
<th scope="col"><%= t("polls.show.stats.total") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><%= t("polls.show.stats.valid") %></th>
|
<th scope="row"><%= t("polls.show.stats.valid") %></th>
|
||||||
|
|
||||||
|
<% Poll::Stats::CHANNELS.each do |channel| %>
|
||||||
<td>
|
<td>
|
||||||
<%= @stats[:total_web_valid] %>
|
<%= @stats[:"total_#{channel}_valid"] %>
|
||||||
<small><em>(<%= @stats[:valid_percentage_web].round(2) %>%)</em></small>
|
<small><em>(<%= @stats[:"valid_percentage_#{channel}"].round(2) %>%)</em></small>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= @stats[:total_booth_valid] %>
|
|
||||||
<small><em>(<%= @stats[:valid_percentage_booth].round(2) %>%)</em></small>
|
|
||||||
</td>
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<%= @stats[:total_valid_votes] %>
|
<%= @stats[:total_valid_votes] %>
|
||||||
<small><em>(<%= @stats[:total_valid_percentage].round(2) %>%)</em></small>
|
<small><em>(<%= @stats[:total_valid_percentage].round(2) %>%)</em></small>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><%= t("polls.show.stats.white") %></th>
|
<th scope="row"><%= t("polls.show.stats.white") %></th>
|
||||||
|
|
||||||
|
<% Poll::Stats::CHANNELS.each do |channel| %>
|
||||||
<td>
|
<td>
|
||||||
<%= @stats[:total_web_white] %>
|
<%= @stats[:"total_#{channel}_white"] %>
|
||||||
<small><em>(<%= @stats[:white_percentage_web].round(2) %>%)</em></small>
|
<small><em>(<%= @stats[:"white_percentage_#{channel}"].round(2) %>%)</em></small>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= @stats[:total_booth_white] %>
|
|
||||||
<small><em>(<%= @stats[:white_percentage_booth].round(2) %>%)</em></small>
|
|
||||||
</td>
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<td><%= @stats[:total_white_votes] %>
|
<td><%= @stats[:total_white_votes] %>
|
||||||
<small><em>(<%= @stats[:total_white_percentage].round(2) %>%)</em></small>
|
<small><em>(<%= @stats[:total_white_percentage].round(2) %>%)</em></small>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><%= t("polls.show.stats.null_votes") %></th>
|
<th scope="row"><%= t("polls.show.stats.null_votes") %></th>
|
||||||
|
|
||||||
|
<% Poll::Stats::CHANNELS.each do |channel| %>
|
||||||
<td>
|
<td>
|
||||||
<%= @stats[:total_web_null] %>
|
<%= @stats[:"total_#{channel}_null"] %>
|
||||||
<small><em>(<%= @stats[:null_percentage_web].round(2) %>%)</em></small>
|
<small><em>(<%= @stats[:"null_percentage_#{channel}"].round(2) %>%)</em></small>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= @stats[:total_booth_null] %>
|
|
||||||
<small><em>(<%= @stats[:null_percentage_booth].round(2) %>%)</em></small>
|
|
||||||
</td>
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<%= @stats[:total_null_votes] %>
|
<%= @stats[:total_null_votes] %>
|
||||||
<small><em>(<%= @stats[:total_null_percentage].round(2) %>%)</em></small>
|
<small><em>(<%= @stats[:total_null_percentage].round(2) %>%)</em></small>
|
||||||
@@ -82,14 +84,14 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><%= t("polls.show.stats.total") %></th>
|
<th scope="row"><%= t("polls.show.stats.total") %></th>
|
||||||
|
|
||||||
|
<% Poll::Stats::CHANNELS.each do |channel| %>
|
||||||
<td>
|
<td>
|
||||||
<%= @stats[:total_participants_web] %>
|
<%= @stats[:"total_participants_#{channel}"] %>
|
||||||
<small><em>(<%= @stats[:total_participants_web_percentage].round(2) %>%)</em></small>
|
<small><em>(<%= @stats[:"total_participants_#{channel}_percentage"].round(2) %>%)</em></small>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= @stats[:total_participants_booth] %>
|
|
||||||
<small><em>(<%= @stats[:total_participants_booth_percentage].round(2) %>%)</em></small>
|
|
||||||
</td>
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<td><%= @stats[:total_participants] %></td>
|
<td><%= @stats[:total_participants] %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user