Files
sure/app/models/balance_sheet
Juan José MataandClaude 4d1d33f91d perf: memoize Family#balance_sheet and sync status lookups per request (#2553)
Family#balance_sheet built a new BalanceSheet on every call. The
application layout renders the account sidebar twice per page (desktop
+ mobile) with three tab panels each, and each panel asks the family
for its balance sheet - so the account, sync-status and exchange-rate
queries behind it ran up to six times per request.

- Memoize Family#balance_sheet per user id (Current.family is the same
  instance for the whole request, and jobs/controllers use short-lived
  Family objects, so staleness is not a concern).
- Memoize BalanceSheet::SyncStatusMonitor#syncing_account_ids in the
  instance: it is called once per account row, and each call was a
  Rails.cache round-trip (or a full re-query with the test null store).

Measured on the test suite probes: ReportsController#index view time
230ms -> 155ms, AccountsController#show 299ms -> 233ms.


Claude-Session: https://claude.ai/code/session_01RpZe2ajeGkPRRBHfaJTfUB

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-22 08:25:02 +02:00
..