mirror of
https://github.com/we-promise/sure.git
synced 2026-09-04 22:31:07 +00:00
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>