Stop scanning every market x product after the answer is known

PerformanceSecurityService
Shipped
August 21, 2026 at 1:36 AM UTC
Author
Kamo
Commit
5a8186f

/leads/available-summary returns three things — hasAcceptable, hasAcceptableCredit and one example product — but visited every market x product pair regardless, issuing 2-4 queries each (eligibility, allotment, and up to two credit counts). At the current 6 markets / 33 products that is roughly 75-140 queries per call, on a path the lead-alert context re-fires from four realtime events on a 350 ms debounce. The scan now stops once all three answers are set, because nothing later can change them. Pure short-circuit: every path that assigns them is untouched, and a run that never satisfies the condition behaves exactly as before. In the common case — the member has credit on the first product — it collapses ~30 iterations to one. Deliberately NOT a rewrite of the loop body. It carries state-licensing eligibility and allotment-precedence logic, and the safe win here was the one I could reason about completely.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing