Polls' stats migrated from Madrid's fork and sortable functions added for tables

This commit is contained in:
iagirre
2017-10-23 13:19:22 +02:00
parent e6384bd5df
commit 5a3e701e8d
6 changed files with 121 additions and 1 deletions

View File

@@ -0,0 +1,87 @@
<%= back_link_to %>
<h2 id="top"><%= t("admin.stats.polls.title")%></h2>
<div class="stats">
<div class="row stats-numbers">
<div class="small-12 medium-3 column">
<p class="featured">
<%= t("admin.stats.polls.web_participants") %><br>
<span id="web_participants" class="number">
<%= @participants.web.select(:user_id).distinct.count %>
</span>
</p>
</div>
<div class="small-12 medium-3 column end">
<p class="featured">
<%= t("admin.stats.polls.total_participants") %><br>
<span id="participants" class="number">
<%= @participants.select(:user_id).distinct.count %>
</span>
</p>
</div>
</div>
</div>
<h2><%= t("admin.stats.polls.all") %></h2>
<table id="polls" class="stack sortable">
<thead>
<tr>
<th><%= t("admin.stats.polls.table.poll_name") %></th>
<th class="name text-right"><%= t("admin.stats.polls.total_participants") %></th>
<th class="name text-right"><%= t("admin.stats.polls.table.origin_web") %></th>
</tr>
</thead>
<% @polls.each do |poll| %>
<tr id="<%= dom_id(poll) %>">
<td class="name">
<a href="#<%= dom_id(poll) %>_questions"><%= poll.name %></a>
</td>
<td class="name text-right">
<%= poll.voters.select(:user_id).distinct.count %>
</td>
<td class="name text-right">
<%= poll.voters.web.select(:user_id).distinct.count %>
</td>
</tr>
<% end %>
</table>
<% @polls.each do |poll| %>
<h3 id="<%= dom_id(poll) %>_questions">
<%= t("admin.stats.polls.poll_questions", poll: poll.name) %>
</h3>
<table class="stack sortable">
<thead>
<tr>
<th><%= t("admin.stats.polls.table.question_name") %></th>
<th class="name text-right">
<%= t("admin.stats.polls.table.origin_web") %>
</th>
</tr>
</thead>
<% poll.questions.each do |question| %>
<tr id="<%= dom_id(question) %>">
<td class="name">
<%= question.title %>
</td>
<td class="name text-right">
<%= ::Poll::Answer.by_question(question).count %>
</td>
</tr>
<% end %>
<tfoot>
<tr id="<%= dom_id(poll) %>_questions_total">
<th></th>
<th class="name text-right">
<strong>
<%= t("admin.stats.polls.table.origin_total") %>:
<%= ::Poll::Answer.where(question: poll.questions)
.select(:author_id).distinct.count %>
</strong>
</th>
</tr>
</tfoot>
</table>
<% end %>

View File

@@ -7,6 +7,8 @@
<h1 class="inline-block"><%= t "admin.stats.show.stats_title" %></h1>
<div class="float-right clear">
<%= link_to t("admin.stats.show.polls"),
polls_admin_stats_path, class: "button hollow" %>
<%= link_to t("admin.stats.show.direct_messages"),
direct_messages_admin_stats_path, class: "button hollow" %>
<%= link_to t("admin.stats.show.proposal_notifications"),