Improve budget stats page with a new row showing each column totals
This commit is contained in:
@@ -134,6 +134,7 @@ class Budget
|
|||||||
end
|
end
|
||||||
|
|
||||||
groups[:total] = Hash.new(0)
|
groups[:total] = Hash.new(0)
|
||||||
|
groups[:total][:total_investments_count] = groups.collect {|_k, v| v[:total_investments_count]}.sum
|
||||||
groups[:total][:total_participants_support_phase] = groups.collect {|_k, v| v[:total_participants_support_phase]}.sum
|
groups[:total][:total_participants_support_phase] = groups.collect {|_k, v| v[:total_participants_support_phase]}.sum
|
||||||
groups[:total][:total_participants_vote_phase] = groups.collect {|_k, v| v[:total_participants_vote_phase]}.sum
|
groups[:total][:total_participants_vote_phase] = groups.collect {|_k, v| v[:total_participants_vote_phase]}.sum
|
||||||
groups[:total][:total_participants_all_phase] = groups.collect {|_k, v| v[:total_participants_all_phase]}.sum
|
groups[:total][:total_participants_all_phase] = groups.collect {|_k, v| v[:total_participants_all_phase]}.sum
|
||||||
@@ -152,6 +153,7 @@ class Budget
|
|||||||
|
|
||||||
def calculate_heading_totals(heading)
|
def calculate_heading_totals(heading)
|
||||||
{
|
{
|
||||||
|
total_investments_count: heading.investments.count,
|
||||||
total_participants_support_phase: voters_by_heading(heading).uniq.count,
|
total_participants_support_phase: voters_by_heading(heading).uniq.count,
|
||||||
total_participants_vote_phase: balloters_by_heading(heading.id).uniq.count,
|
total_participants_vote_phase: balloters_by_heading(heading.id).uniq.count,
|
||||||
total_participants_all_phase: voters_and_balloters_by_heading(heading)
|
total_participants_all_phase: voters_and_balloters_by_heading(heading)
|
||||||
|
|||||||
@@ -167,7 +167,7 @@
|
|||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<h2 class="margin-bottom"><%= t("budgets.stats.by_heading") %></h2>
|
<h2 class="margin-bottom"><%= t("budgets.stats.by_heading") %></h2>
|
||||||
|
|
||||||
<table class="stats-districts">
|
<table class="stats-districts survey-districts">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" rowspan="2"><%= t("budgets.stats.heading") %></th>
|
<th scope="col" rowspan="2"><%= t("budgets.stats.heading") %></th>
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td id="total_spending_proposals_heading_<%= heading.id %>"
|
<td id="total_spending_proposals_heading_<%= heading.id %>"
|
||||||
class="text-center border-left border-right">
|
class="text-center border-left border-right">
|
||||||
<%= heading.investments.count %>
|
<%= @stats[:headings][heading.id][:total_investments_count] %>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<% ["support", "vote", "all"].each do |phase| %>
|
<% ["support", "vote", "all"].each do |phase| %>
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
<%= @stats[:headings][heading.id]["total_participants_#{phase}_phase".to_sym] %>
|
<%= @stats[:headings][heading.id]["total_participants_#{phase}_phase".to_sym] %>
|
||||||
</td>
|
</td>
|
||||||
<td id="percentage_participants_<%= phase %>_phase_heading_<%= heading.id %>"
|
<td id="percentage_participants_<%= phase %>_phase_heading_<%= heading.id %>"
|
||||||
class="border-left border-right text-center %>">
|
class="border-left border-right text-center">
|
||||||
<%= number_to_percentage(@stats[:headings][heading.id]["percentage_participants_#{phase}_phase".to_sym],
|
<%= number_to_percentage(@stats[:headings][heading.id]["percentage_participants_#{phase}_phase".to_sym],
|
||||||
strip_insignificant_zeros: true,
|
strip_insignificant_zeros: true,
|
||||||
precision: 2) %>
|
precision: 2) %>
|
||||||
@@ -220,6 +220,29 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<tr id="headings_totals">
|
||||||
|
<td class="text-center border-left-success success">
|
||||||
|
<strong><%= t("budgets.stats.total").upcase %></strong>
|
||||||
|
</td>
|
||||||
|
<td id="total_spending_proposals_heading_total"
|
||||||
|
class="text-center success">
|
||||||
|
<strong><%= @stats[:headings][:total][:total_investments_count] %></strong>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<% ["support", "vote", "all"].each do |phase| %>
|
||||||
|
<td id="total_participants_<%= phase %>_phase_heading_total"
|
||||||
|
class="text-center success">
|
||||||
|
<strong><%= @stats[:headings][:total]["total_participants_#{phase}_phase".to_sym] %></strong>
|
||||||
|
</td>
|
||||||
|
<td id="percentage_participants_<%= phase %>_phase_heading_total"
|
||||||
|
class="text-center success">
|
||||||
|
<strong><%= number_to_percentage(@stats[:headings][:total]["percentage_participants_#{phase}_phase".to_sym],
|
||||||
|
strip_insignificant_zeros: true,
|
||||||
|
precision: 2) %></strong>
|
||||||
|
</td>
|
||||||
|
<td class="text-center success <%= phase == "all" ? "border-right-success " : "" %>"></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user