Org home Overview data

Classification: Internal-Only

GET /api/v1/organization/overview serves the org home Overview cards. It is a temporary solution, called only by tofu-web; a stored daily table replaces the queries later.

Nothing is stored. bonsapi reads the source tables, caches each org’s result in Redis for 15 minutes and narrows it per viewer. A range must start within the last 92 days, so one rolling copy per org serves every request. There is no usage block: tofu-web’s Usage card reads GET /billings.

Cache keys (Redis), for clearing an org’s Overview while testing:

  • bonsai-app:{org_id}:overview:activity:recent:v1: the rolling last-93-days result
  • each key’s :lock and :failed siblings (refresh lock, 60 s failure pause)

Deleting the result keys forces the next call to recount. The Clients tab’s To review counts are cached separately for 30 s.

Number Definition
Types Every extraction document type: AP bill, AR invoice, direct expense, bank statement, AP and AR credit note, and expense claim.
Excluded Deleted extractions and onboarding (demo) extractions.
Bank statements Once per primary page; supporting pages don’t count (as billing).
In tofu / outside In tofu when the latest data was read by tofu’s AI or source = 'TOFU' (v1’s rule). Counted on the day the extraction was created.
Days UTC.

The queries live in libs/rust/bonsai-database/src/sqlx/sqlx_activity_repository.rs, the one definition of each number.