fix: populate short interest cache directly instead of relying on clogged drain queue

The stale-while-revalidate pattern queues background fetches via the AdapterQueue,
but with 227+ pending jobs, short interest keys take too long to process.
Users saw empty panels on every symbol because the fetch never completed before
the response returned.

Fix:
- shortInterest procedure: when Yahoo + NASDAQ caches are both empty, fetch
  directly via the adapters, store in cache, and return — all within the request.
  Subsequent requests hit the cache. Bypasses the clogged queue entirely.
- FinraBulkAdapter: guard against per-symbol keys (non-'latest' and non-date IDs)
  by returning a skipped result instead of trying to download a file named
  after the ticker.
- finraShortInterest handler: return isStale=false when no data is in the table,
  so per-symbol reads never trigger queue fetches (FINRA is schedule-only).
  Router stale computation now excludes FINRA from the combined stale flag.
This commit is contained in:
Investor Flow Build
2026-07-25 13:23:07 -04:00
parent 3d12f50418
commit 04fc11b2fd
3 changed files with 41 additions and 4 deletions
+4 -1
View File
@@ -340,7 +340,10 @@ const finraShortInterestHandler: KindHandler = {
write(_d, _symbol, _value, _provenance) {
// FINRA data is bulk-ingested via FinraIngestService; no per-symbol write needed.
},
isStale(ts, now) { return tsAgeMs(ts, now) > TTL_MS.short_interest; },
isStale(ts, now) {
if (ts === null) return false; // schedule-only; never queue per-symbol fetches
return tsAgeMs(ts, now) > TTL_MS.short_interest;
},
};
const HANDLERS = new Map<string, KindHandler>([