From dd851cb6cc57cd92338f7b0f77164f796eee8b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 29 May 2019 18:52:23 +0200 Subject: [PATCH] Add task to regenerate ballot_lines_count cache We've added this column recently to `budget_ballots`, and we use it to calculate stats. --- lib/tasks/regenerate_ballot_lines_cache.rake | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lib/tasks/regenerate_ballot_lines_cache.rake diff --git a/lib/tasks/regenerate_ballot_lines_cache.rake b/lib/tasks/regenerate_ballot_lines_cache.rake new file mode 100644 index 000000000..d008ec556 --- /dev/null +++ b/lib/tasks/regenerate_ballot_lines_cache.rake @@ -0,0 +1,8 @@ +namespace :budgets do + desc "Regenerate ballot_lines_count cache" + task calculate_ballot_lines: :environment do + Budget::Ballot.find_each do |ballot| + Budget::Ballot.reset_counters ballot.id, :lines + end + end +end