From 50c0f5f2873c5fa9b31e4f39821b1ad1ea843bf2 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Sat, 1 Jul 2017 00:05:54 +0200 Subject: [PATCH] more efficient calculation of ballot lines --- app/models/budget/stats.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/budget/stats.rb b/app/models/budget/stats.rb index 643c4fda0..dda71554b 100644 --- a/app/models/budget/stats.rb +++ b/app/models/budget/stats.rb @@ -31,7 +31,7 @@ class Budget end def total_votes - stats_cache("total_votes") { @budget.ballots.map(&:lines).count } + stats_cache("total_votes") { @budget.ballots.pluck(:ballot_lines_count).inject(0) { |sum, x| sum + x } } end def total_selected_investments