Skip to content

Commit

Permalink
Merge pull request #72 from StemvanGroningen/budget_admin_stats
Browse files Browse the repository at this point in the history
Count only positive supports on admin budget stats
  • Loading branch information
decabeza committed Oct 20, 2020
2 parents e59c942 + 21d1e84 commit 0973af4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/stats_controller.rb
Expand Up @@ -58,7 +58,7 @@ def budget_supporting
@budget = Budget.find(params[:budget_id])
heading_ids = @budget.heading_ids

votes = Vote.where(votable_type: "Budget::Investment").
votes = Vote.where(votable_type: "Budget::Investment", vote_flag: true).
includes(:budget_investment).
where(budget_investments: { heading_id: heading_ids })

Expand Down
1 change: 0 additions & 1 deletion app/controllers/stats_controller.rb
Expand Up @@ -14,7 +14,6 @@ def index
@debate_votes = daily_cache("debate_votes") { Vote.where(votable_type: "Debate").count }
@proposal_votes = daily_cache("proposal_votes") { Vote.where(votable_type: "Proposal").count }
@comment_votes = daily_cache("comment_votes") { Vote.where(votable_type: "Comment").count }
@investment_votes = daily_cache("budget_investment_votes") { Vote.where(votable_type: "Budget::Investment").count }
@votes = daily_cache("votes") { Vote.count }

@verified_users = daily_cache("verified_users") { User.with_hidden.level_two_or_three_verified.count }
Expand Down
3 changes: 3 additions & 0 deletions spec/features/admin/stats_spec.rb
Expand Up @@ -104,6 +104,9 @@

create(:budget_investment, heading: create(:budget_heading, group: group_2), voters: [create(:user)])
create(:budget_investment, heading: heading_all_city, voters: [create(:user), create(:user)])
investment_retired_supports = create(:budget_investment, heading: heading_all_city)

3.times { create(:vote, votable: investment_retired_supports, vote_flag: false) }

visit admin_stats_path
click_link "Participatory Budgets"
Expand Down

0 comments on commit 0973af4

Please sign in to comment.