Files
sure/test
ghost a21ab1946e perf(accounts): preload transfer, category, and split-parent associations on show (#2441)
* perf(accounts): preload transfer, category, and split-parent associations on show

AccountsController#show iterated over paginated entries and called
transaction.transfer (two queries via transfer_as_inflow || transfer_as_outflow),
transaction.category, and transaction.merchant individually per row, and fell
back to entry.split_parent? (child_entries.exists? per entry) because
@split_parent_entry_ids was never set.

Fix by:
- Batch-preloading transfer_as_inflow, transfer_as_outflow, category, and merchant
  on transaction entryables after pagination using Associations::Preloader (same
  API already used in accounts/index/_account_groups.erb).
- Setting @split_parent_entry_ids with a single IN query after pagination,
  matching the identical pattern already in TransactionsController#index.

Resolves Sentry issues SURE-APP-PN (60 users), SURE-APP-XE (32 users),
SURE-APP-26 (51 users) and related slow-DB reports on AccountsController#show.

* docs(accounts): note the show preload is intentionally page-scoped

Address review feedback (jjmata): add a comment clarifying that the transfer/
category/merchant preload and the split-parent lookup operate on the current
page (@entries) by design — only this page is rendered, so a child entry whose
split parent is on another page deliberately won't resolve it. Comment-only; no
behavior change.
2026-07-30 03:42:50 +02:00
..
2024-02-02 09:05:04 -06:00