Extract component for balloting budget admin stats

We're also moving the tests, but we're keeping one system test in order
to test the controller and the navigation to get to this page.

Note we're slightly changing the order of the methods in the component;
the order of the instance variables was `user_`, `vote_`, `vote_`,
`user_`, which was hard to follow.
This commit is contained in:
Javi Martín
2023-02-02 19:49:52 +01:00
parent 915999db4a
commit 76b08398cf
6 changed files with 111 additions and 78 deletions

View File

@@ -75,14 +75,6 @@ class Admin::StatsController < Admin::BaseController
@budget = Budget.find(params[:budget_id])
authorize! :read_admin_stats, @budget, message: t("admin.stats.budgets.no_data_before_balloting_phase")
@user_count = @budget.ballots.select { |ballot| ballot.lines.any? }.count
@vote_count = @budget.lines.count
@vote_count_by_heading = @budget.lines.group(:heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
end
def polls