Skip to content

armgit / maybe

Public Imported from GitHub
0

The personal finance app for everyone

fix n+1 for categories (#1693)

Georgi Tapalilovd2a7aef6efc6
diff --git a/app/models/budget.rb b/app/models/budget.rb
index d59e9d41..9f6d6c07 100644
--- a/app/models/budget.rb
+++ b/app/models/budget.rb
@@ -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