adds budget stats for final voting to admin stats

This commit is contained in:
Juanjo Bazán
2017-05-24 14:26:36 +02:00
committed by Javi Martín
parent 5be54b57da
commit 110ee961e3
9 changed files with 209 additions and 70 deletions

View File

@@ -74,6 +74,17 @@ class Admin::StatsController < Admin::BaseController
end
end
def budget_balloting
@budget = Budget.find(params[:budget_id])
@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.collect {|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.collect {|k,v| [Budget::Heading.find(k).name, v]}.sort
end
def polls
@polls = ::Poll.current
@participants = ::Poll::Voter.where(poll: @polls)