From a13a8a2270610e2db9028d6a53a6c81b557d85f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 20 Mar 2019 14:00:05 +0100 Subject: [PATCH] Simplify code to calculate supports The code is easier to read now, it returns the same results it used to return, and performance-wise it's probably the same thing, but if it's not, we'll trust Rails will do optimizations that we don't when we manually pluck the IDs. --- 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 7cd4d40f1..513fc0af4 100644 --- a/app/models/budget/stats.rb +++ b/app/models/budget/stats.rb @@ -130,7 +130,7 @@ class Budget::Stats end def supports(supportable) - ActsAsVotable::Vote.where(votable_type: "Budget::Investment", votable_id: supportable.investments.pluck(:id)) + Vote.where(votable: supportable.investments) end stats_cache(*stats_methods)