← back to Dw Photo Capture
Incoming queue: best-effort image enrichment — pass 2 in the background refresh resolves CATALOG-miss samples via identifyUnified (full 267k crossref + 173k shopify_products), concurrency-bounded (6 workers), serve-stale-while-enriching. 0/40 -> 16/40 (40%) thumbnails + real pattern names; also populates dw_sku/mfr_sku so scan-match highlights more incoming cards
62ce2a4007aedfab70e3238724a630f06a1a3464 · 2026-07-08 06:58:24 -0700 · Steve Abrams
Files touched
Diff
commit 62ce2a4007aedfab70e3238724a630f06a1a3464
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Jul 8 06:58:24 2026 -0700
Incoming queue: best-effort image enrichment — pass 2 in the background refresh resolves CATALOG-miss samples via identifyUnified (full 267k crossref + 173k shopify_products), concurrency-bounded (6 workers), serve-stale-while-enriching. 0/40 -> 16/40 (40%) thumbnails + real pattern names; also populates dw_sku/mfr_sku so scan-match highlights more incoming cards
---
server.js | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index e565847..c663661 100644
--- a/server.js
+++ b/server.js
@@ -38,14 +38,29 @@ async function refreshIncoming() {
const floor = new Date(Date.now() - 120 * 864e5).toLocaleDateString('en-US', { timeZone: process.env.FM_TZ || 'America/Los_Angeles', year: 'numeric', month: '2-digit', day: '2-digit' });
const r = await FM.fmFind(FM_DB, FM_LAYOUT, [{ 'Date Sample Request printed for vendor': '>=' + floor, 'Date WP Sample Sent': '=' }], { limit: 40, portal: [] });
const recs = (r.records || []);
- _incomingCache = { at: Date.now(), samples: recs.map(rec => { const f = rec.fieldData;
+ // Pass 1 — spec-first from the in-RAM active CATALOG (instant, $0). Serve this immediately.
+ const samples = recs.map(rec => { const f = rec.fieldData;
const nk = nmfr(f['Mfr Pattern'] || f['combo sku'] || '');
const hit = nk ? CATALOG.find(x => x.mfr && nmfr(x.mfr) === nk) : null;
return { recordId: rec.recordId, mfr_pattern: f['Mfr Pattern'] || null, combo_sku: f['combo sku'] || null,
series: f['Series'] || null, vid: f['vid'] || null, client: f['company for client fileS'] || null,
vendor_ordered: f['Date Sample Request printed for vendor'] || null, client_ordered: f['today for client'] || null,
image: (hit && hit.image) || null, pattern: (hit && hit.title) || null,
- dw_sku: (hit && hit.dw_sku) || null, mfr_sku: (hit && hit.mfr) || null }; }) };
+ dw_sku: (hit && hit.dw_sku) || null, mfr_sku: (hit && hit.mfr) || null }; });
+ _incomingCache = { at: Date.now(), samples };
+ // Pass 2 — best-effort images for the CATALOG misses via identifyUnified (full 267k crossref +
+ // 173k shopify_products, much wider net). Runs in the BACKGROUND, mutating the served cache in
+ // place (serve-stale-while-enriching); concurrency-bounded so 40 samples don't fork 80 psql shells.
+ const misses = samples.filter(s => !s.image);
+ let idx = 0;
+ const worker = async () => { while (idx < misses.length) { const s = misses[idx++];
+ let id = s.mfr_pattern ? await identifyUnified(s.mfr_pattern).catch(() => null) : null;
+ if ((!id || !id.image) && s.combo_sku) id = await identifyUnified(s.combo_sku).catch(() => null) || id;
+ if (id) { if (id.image && !s.image) s.image = id.image;
+ if (!s.pattern) s.pattern = id.pattern || id.title || s.pattern;
+ if (!s.mfr_sku) s.mfr_sku = id.mfr_sku || s.mfr_sku;
+ if (!s.dw_sku) s.dw_sku = id.internal_sku_dash || id.internal_sku || s.dw_sku; } } };
+ await Promise.all(Array.from({ length: Math.min(6, misses.length) }, worker));
} catch (e) { /* keep last good cache */ }
_incomingLoading = false;
}
← 999db25 Check Sample In: 'Received' button stamps Date WP Sample Sen
·
back to Dw Photo Capture
·
browse whole dw_unified catalog via all-dw feed (was Fentucc a4417e3 →