Coalesce pool-availability recounts instead of recounting per lead

Fixkamo-shared-library
Shipped
September 16, 2026 at 3:40 PM UTC
Author
Kamo
Commit
d6210f7

countAssignablePool scans every lead in the org+market and ran synchronously after every createLead commit. At ~14k leads it already cost ~165 ms, more than the insert; a bulk intake of hundreds of thousands of leads would spend seconds per lead recounting. Recounts are now queued per (org, product, market) and run once after a 2 s window; the key is cleared before counting so the trailing figure always includes the last lead.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing