add budget investment stats
This commit is contained in:
@@ -52,9 +52,29 @@ 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)
|
||||
@vote_count = votes.count
|
||||
@participant_count = votes.select(:voter_id).distinct.count
|
||||
|
||||
@voters_in_heading = {}
|
||||
budget = Budget.last
|
||||
budget.headings.each do |heading|
|
||||
@voters_in_heading[heading] = voters_in_heading(heading)
|
||||
end
|
||||
end
|
||||
|
||||
def polls
|
||||
@polls = ::Poll.current
|
||||
@participants = ::Poll::Voter.where(poll: @polls)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def voters_in_heading(heading)
|
||||
Vote.where(votable_type: "Budget::Investment").
|
||||
includes(:budget_investment).
|
||||
where(budget_investments: { heading_id: heading.id }).
|
||||
select("votes.voter_id").distinct.count
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user