improves query on admin stats controller

This commit is contained in:
Alberto Garcia Cabeza
2017-04-26 13:12:55 +02:00
parent f151337080
commit 60d08ab565

View File

@@ -21,8 +21,9 @@ class Admin::StatsController < Admin::BaseController
@user_ids_who_voted_proposals = ActsAsVotable::Vote.where(votable_type: 'Proposal').distinct.count(:voter_id) @user_ids_who_voted_proposals = ActsAsVotable::Vote.where(votable_type: 'Proposal').distinct.count(:voter_id)
@user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals @user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals
@spending_proposals = SpendingProposal.count @spending_proposals = SpendingProposal.count
@budgets = Budget.where.not(phase: 'finished').count budgets_ids = Budget.where.not(phase: 'finished').pluck(:id)
@investments = Budget.where.not(phase: 'finished').collect(&:investments).flatten.count @budgets = budgets_ids.size
@investments = Budget::Investment.where(budget_id: budgets_ids).count
end end
def proposal_notifications def proposal_notifications