fix(reports): eager load investment account associations to prevent N+1 queries

This commit is contained in:
sentry[bot]
2026-05-28 11:14:24 +00:00
committed by GitHub
parent 79ad3e764f
commit 4df4daccb8

View File

@@ -180,7 +180,14 @@ class InvestmentStatement
# Investment accounts
def investment_accounts
@investment_accounts ||= begin
scope = family.accounts.visible.where(accountable_type: %w[Investment Crypto])
scope = family.accounts.visible.with_attached_logo
.where(accountable_type: %w[Investment Crypto])
.includes(
:accountable,
:plaid_account,
:simplefin_account,
account_providers: :provider
)
scope = scope.included_in_finances_for(user) if user
scope
end