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.
This commit is contained in:
Javi Martín
2019-03-20 14:00:05 +01:00
parent 7a79c36137
commit a13a8a2270

View File

@@ -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)