Fix n+1 for categories in for to_donut_segments_json in budget #1693

Merged
tapalilov merged 1 commits from fix-category-n_plus_1 into main 2025-01-27 22:34:13 +08:00

View File

@@ -94,7 +94,7 @@ class Budget < ApplicationRecord
# Continuous gray segment for empty budgets
return [ { color: "#F0F0F0", amount: 1, id: unused_segment_id } ] unless allocations_valid?
segments = budget_categories.map do |bc|
segments = budget_categories.includes(:category).map do |bc|
{ color: bc.category.color, amount: bc.actual_spending, id: bc.id }
end