Skip to content

Commit

Permalink
fix N+1 query
Browse files Browse the repository at this point in the history
  • Loading branch information
“Apoorv committed Mar 8, 2024
1 parent 6746f6c commit ea9d81a
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ def total_expenses_sum
end

def default_category_expenses
Expense.where(expense_category: ExpenseCategory.default_categories, company_id: current_company.id)
Expense.includes(:expense_category).where(
expense_category: ExpenseCategory.default_categories,
company_id: current_company.id)
end

def company_expenses_categories
Expense.where(expense_category: current_company.expense_categories)
Expense.includes(:expense_category).where(expense_category: current_company.expense_categories)
end

def formatted_expenses_sum(expenses)
Expand Down

0 comments on commit ea9d81a

Please sign in to comment.