<%= t("admin.polls.show.results_title") %>

<% if @poll.partial_results.empty? %>
<%= t("admin.polls.show.no_results") %>
<% else %>
<%= t("admin.polls.show.table_whites") %> <%= t("admin.polls.show.table_nulls") %>
<%= @poll.white_results.sum(:amount) %> <%= @poll.null_results.sum(:amount) %>
<% by_question = @poll.partial_results.group_by(&:question_id) %> <% @poll.questions.each do |question| %>

<%= question.title %>

<% question.valid_answers.each_with_index do |answer, i| %> <% by_answer = by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {} %> <% end %>
<%= t("admin.polls.show.table_answer") %> <%= t("admin.polls.show.table_votes") %>
<%= answer %> <%= by_answer[answer].present? ? by_answer[answer].sum(&:amount) : 0 %>
<% end %> <% end %>