[object Object]

← back to Stock Vshape Viewer

Wire largeOnly filter end-to-end (default off)

464899cb2b70d355a2598a5ac2d69d7187d7e6eb · 2026-09-15 18:13:15 -0700 · Steve

runScan gained a 5th largeOnly param + cap>=40e9 filter but the only
caller passed 4 args, so largeOnly was always undefined and the filter
was dead. Read it in filtersFromQuery (bool('largeOnly'), defaults off)
and pass filters.largeOnly at the /api/scan/start call site.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pnon7dut9MfPekhhm9YY4Q

Files touched

Diff

commit 464899cb2b70d355a2598a5ac2d69d7187d7e6eb
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Sep 15 18:13:15 2026 -0700

    Wire largeOnly filter end-to-end (default off)
    
    runScan gained a 5th largeOnly param + cap>=40e9 filter but the only
    caller passed 4 args, so largeOnly was always undefined and the filter
    was dead. Read it in filtersFromQuery (bool('largeOnly'), defaults off)
    and pass filters.largeOnly at the /api/scan/start call site.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01Pnon7dut9MfPekhhm9YY4Q
---
 server.js | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/server.js b/server.js
index 59ba81e..67ca4ba 100644
--- a/server.js
+++ b/server.js
@@ -144,10 +144,13 @@ function filtersFromQuery(p) {
   const num = (k, d) => p.has(k) ? +p.get(k) : d, bool = (k) => p.get(k) === 'true';
   return { weeksAgo: num('weeksAgo', 6), weeksTol: num('weeksTol', 3), minDip: num('minDip', 10),
     maxFromHigh: num('maxFromHigh', 60), minPrice: num('minPrice', 8), reqNewHigh: p.has('reqNewHigh') ? bool('reqNewHigh') : true,
-    dipTo50: bool('dipTo50'), dipTo200: bool('dipTo200'), below50: bool('below50'), below200: bool('below200') };
+    dipTo50: bool('dipTo50'), dipTo200: bool('dipTo200'), below50: bool('below50'), below200: bool('below200'),
+    largeOnly: bool('largeOnly') };
 }
-async function runScan(job, filters, tfN, max) {
-  const universe = (await getUniverse(filters.minPrice)).slice(0, max);
+async function runScan(job, filters, tfN, max, largeOnly) {
+  let universe = await getUniverse(filters.minPrice);
+  if (largeOnly) universe = universe.filter(u => u.cap >= 40e9); // validated large-cap tier (Infinity DJIA/major-ETF pass)
+  universe = universe.slice(0, max);
   job.total = universe.length;
   let i = 0;
   async function worker() {
@@ -220,7 +223,7 @@ const server = http.createServer(async (req, res) => {
       const id = 'job' + Date.now().toString(36) + Math.floor(Math.random() * 1e4).toString(36);
       const job = { id, total: 0, scanned: 0, matches: [], done: false, startedAt: Date.now(), abort: false };
       JOBS.set(id, job);
-      runScan(job, filters, tfN, max).catch(e => { job.error = String(e.message || e); job.done = true; });
+      runScan(job, filters, tfN, max, filters.largeOnly).catch(e => { job.error = String(e.message || e); job.done = true; });
       // prune old jobs
       for (const [k, v] of JOBS) if (Date.now() - v.startedAt > 20 * 60 * 1000) JOBS.delete(k);
       return jsonRes(res, 200, { job: id, universe: job.total });

← 21c2528 auto-data-snapshot: 2026-08-28T01:33:48 (1 data files) — .yo  ·  back to Stock Vshape Viewer  ·  (newest)