[object Object]

← back to Dw Pairs Well

WS-1: server.js AUTH_PID prefers title-first pattern_id map (fallback to old mfr-first)

671721db3687e270a07f5c6871ceb79d88fae6b5 · 2026-06-26 12:47:32 -0700 · Steve

Files touched

Diff

commit 671721db3687e270a07f5c6871ceb79d88fae6b5
Author: Steve <steve@designerwallcoverings.com>
Date:   Fri Jun 26 12:47:32 2026 -0700

    WS-1: server.js AUTH_PID prefers title-first pattern_id map (fallback to old mfr-first)
---
 server.js | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/server.js b/server.js
index 860de3a..a139b85 100644
--- a/server.js
+++ b/server.js
@@ -466,16 +466,20 @@ function patternIdFromMetafields(metafields) {
 // /pages/pattern?pattern_id=…::mfr::CORK as 16 unrelated cork designs under one tile.
 // Falls back to the interim derivation for any dw_sku not present in the map.
 const AUTH_PID = (() => {
-  try {
-    const raw = require('./tools/pattern-id-by-dwsku.json');
-    const m = new Map();
-    for (const k in raw) { const v = raw[k]; if (v && v.pid) m.set(k, v.pid); }
-    console.log(`[pattern_id] loaded ${m.size} authoritative grouping keys`);
-    return m;
-  } catch (e) {
-    console.warn('[pattern_id] authoritative map unavailable, using interim derivation:', e.message);
-    return new Map();
+  // WS-1 (2026-06-26): prefer the NEW title-first + color-invariant map (TH=30) — the
+  // same keys re-backfilled to Shopify custom.pattern_id. Falls back to the OLD mfr-first
+  // map only if the new one is absent, so a deploy before the re-backfill never regresses.
+  for (const path of ['./tools/pattern-id-titlefirst-by-dwsku.json', './tools/pattern-id-by-dwsku.json']) {
+    try {
+      const raw = require(path);
+      const m = new Map();
+      for (const k in raw) { const v = raw[k]; if (v && v.pid) m.set(k, v.pid); }
+      console.log(`[pattern_id] loaded ${m.size} authoritative grouping keys from ${path}`);
+      return m;
+    } catch (e) { /* try next */ }
   }
+  console.warn('[pattern_id] authoritative map unavailable, using interim derivation');
+  return new Map();
 })();
 
 // THE canonical grouping key for a product row. Authoritative backfilled key first

← 6476f17 WS-1: set pattern_id image-confirm threshold to 30 (Yakatore  ·  back to Dw Pairs Well  ·  auto-save: 2026-06-26T13:03:32 (3 files) — tools/ci-hash-bui 13c4dfe →