← back to Rentv
pr/edgar: Cody gate — cache company_tickers.json (1h TTL). The ~1MB static file (SEC publishes daily) was fetched + deserialized + O(n)-scanned on EVERY searchCompanies call; now fetched at most once per process-hour via getTickersData(). Removed dead-code cleanup exposed this as the real latency/SEC-fair-access cost. Verified: 3 searches in-window → 1 fetch; after TTL → refetch
b2de6f40607ff42a2d7aa1fb5f881979c5f918b7 · 2026-08-06 01:55:35 -0700 · Steve
Files touched
M src/pr/adapters/edgar.js
Diff
commit b2de6f40607ff42a2d7aa1fb5f881979c5f918b7
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Aug 6 01:55:35 2026 -0700
pr/edgar: Cody gate — cache company_tickers.json (1h TTL). The ~1MB static file (SEC publishes daily) was fetched + deserialized + O(n)-scanned on EVERY searchCompanies call; now fetched at most once per process-hour via getTickersData(). Removed dead-code cleanup exposed this as the real latency/SEC-fair-access cost. Verified: 3 searches in-window → 1 fetch; after TTL → refetch
---
src/pr/adapters/edgar.js | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/pr/adapters/edgar.js b/src/pr/adapters/edgar.js
index 0b3a3ce1..3885a9c4 100644
--- a/src/pr/adapters/edgar.js
+++ b/src/pr/adapters/edgar.js
@@ -14,6 +14,16 @@ async function edgarFetch(url) {
});
}
+// company_tickers.json is a ~1MB static file SEC publishes daily. Cache it (1h TTL) so searchCompanies
+// fetches + deserializes it at most once per process-hour, not on every query (latency + SEC fair-access).
+let _tickers = null, _tickersAt = 0;
+async function getTickersData(url) {
+ if (_tickers && Date.now() - _tickersAt < 3600e3) return _tickers;
+ _tickers = await edgarFetch(url);
+ _tickersAt = Date.now();
+ return _tickers;
+}
+
const adapter = register({
name: 'edgar',
kind: 'discovery',
@@ -34,7 +44,7 @@ const adapter = register({
// company_tickers.json: complete public-company registry (name, ticker, CIK).
// (Removed a preceding browse-edgar `output=atom` fetch: it returns XML, which edgarFetch's
// r.json() can't parse, so it was a guaranteed-failing wasted SEC round-trip on every search.)
- const all = await edgarFetch(tickersUrl);
+ const all = await getTickersData(tickersUrl);
const q = query.toLowerCase();
items = Object.values(all)
.filter((c) => c.title && c.title.toLowerCase().includes(q))
← fd7ccfda pr/edgar: remove a guaranteed-failing wasted SEC request in
·
back to Rentv
·
auto-save: 2026-08-06T02:17:40 (7 files) — data/deals-regist b37f2aba →