diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index c65b04162..75d79b57b 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -52,14 +52,24 @@ class Admin::StatsController < Admin::BaseController @users_who_have_sent_message = DirectMessage.select(:sender_id).distinct.count end - def budget_investments - votes = Vote.for_budget_investments(Budget::Investment.all) + + def budgets + @budgets = Budget.all + end + + def budget_supporting + @budget = Budget.find(params[:budget_id]) + heading_ids = @budget.heading_ids + + votes = Vote.where(votable_type: "Budget::Investment"). + includes(:budget_investment). + where(budget_investments: { heading_id: heading_ids }) + @vote_count = votes.count - @participant_count = votes.select(:voter_id).distinct.count + @user_count = votes.select(:voter_id).distinct.count @voters_in_heading = {} - budget = Budget.last - budget.headings.each do |heading| + @budget.headings.each do |heading| @voters_in_heading[heading] = voters_in_heading(heading) end end diff --git a/app/views/admin/stats/budget_investments.html.erb b/app/views/admin/stats/budget_supporting.html.erb similarity index 68% rename from app/views/admin/stats/budget_investments.html.erb rename to app/views/admin/stats/budget_supporting.html.erb index c3942cc5c..ba079c1c8 100644 --- a/app/views/admin/stats/budget_investments.html.erb +++ b/app/views/admin/stats/budget_supporting.html.erb @@ -2,11 +2,15 @@ <%= javascript_include_tag "stat_graphs", "data-turbolinks-track" => true %> <% end %> +<%= back_link_to budgets_admin_stats_path %> + +
- <%= t("admin.stats.budget_investments.vote_count") %>
+ <%= t("admin.stats.budget_supporting.vote_count") %>
- <%= t("admin.stats.budget_investments.participant_count") %>
+ <%= t("admin.stats.budget_supporting.participant_count") %>
<%= @vote_count %>
@@ -16,21 +20,21 @@
- <%= @participant_count %>
+ <%= @user_count %>
| <%= t("admin.stats.budget_investments.groups") %> | -<%= t("admin.stats.budget_investments.users") %> | +<%= t("admin.stats.budget_supporting.groups") %> | +<%= t("admin.stats.budget_supporting.users") %> | <% @voters_in_heading.each do |heading, count| %>
|---|---|
| + <%= budget.name %> + | ++ <%= link_to t("admin.stats.budgets.supporting_phase"), budget_supporting_admin_stats_path(budget_id: budget.id), class: "button hollow" %> + | +
<%= link_to t("admin.stats.show.summary.visits"),
- graph_admin_stats_path(id: "visits", count: @visits) %>
+ graph_admin_stats_path(id: "visits", count: @visits) %>
<%= number_with_delimiter(@visits) %>