mirror of
https://github.com/we-promise/sure.git
synced 2026-05-29 23:39:03 +00:00
fix(reports): eager load investment account associations to prevent N+1 queries
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user