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:
@@ -130,7 +130,7 @@ class Budget::Stats
|
|||||||
end
|
end
|
||||||
|
|
||||||
def supports(supportable)
|
def supports(supportable)
|
||||||
ActsAsVotable::Vote.where(votable_type: "Budget::Investment", votable_id: supportable.investments.pluck(:id))
|
Vote.where(votable: supportable.investments)
|
||||||
end
|
end
|
||||||
|
|
||||||
stats_cache(*stats_methods)
|
stats_cache(*stats_methods)
|
||||||
|
|||||||
Reference in New Issue
Block a user