← back to Designer Wallcoverings
Carl Robinson: unique running 6-digit SKU numbers across book (no per-series repeat)
366e5801a1b9dd3699ede3719fa0f0d3b223b666 · 2026-07-06 12:16:26 -0700 · steve@designerwallcoverings.com
Files touched
M scripts/wallquest-refresh/remap-skus-carl-robinson.cjs
Diff
commit 366e5801a1b9dd3699ede3719fa0f0d3b223b666
Author: steve@designerwallcoverings.com <steve@designerwallcoverings.com>
Date: Mon Jul 6 12:16:26 2026 -0700
Carl Robinson: unique running 6-digit SKU numbers across book (no per-series repeat)
---
.../wallquest-refresh/remap-skus-carl-robinson.cjs | 24 ++++++++++++++--------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/scripts/wallquest-refresh/remap-skus-carl-robinson.cjs b/scripts/wallquest-refresh/remap-skus-carl-robinson.cjs
index 2e911051..bd4b1096 100644
--- a/scripts/wallquest-refresh/remap-skus-carl-robinson.cjs
+++ b/scripts/wallquest-refresh/remap-skus-carl-robinson.cjs
@@ -18,16 +18,20 @@ const numOf = r => parseInt((String(r.mfr_sku).match(/\d+/) || ['0'])[0], 10);
(async () => {
const enr = JSON.parse(fs.readFileSync(ENR, 'utf8'));
- // sequential per material, ordered by mfr number
+ // ONE continuous, globally-unique 6-digit sequence (>100000) across the whole book,
+ // grouped by material (largest series first), ordered by mfr number within each.
const byMat = {};
for (const r of enr) (byMat[materialOf(r.pattern)] = byMat[materialOf(r.pattern)] || []).push(r);
const seqBySku = {}; // mfr_sku -> new sku
- const dist = {};
- for (const [mat, rows] of Object.entries(byMat)) {
+ const dist = {}, ranges = {};
+ let n = 100001;
+ const mats = Object.keys(byMat).sort((a, b) => byMat[b].length - byMat[a].length || a.localeCompare(b));
+ for (const mat of mats) {
const code = CODE[mat] || 'NAT';
- rows.sort((a, b) => numOf(a) - numOf(b));
- rows.forEach((r, i) => { seqBySku[r.mfr_sku] = `${code}-${100000 + i + 1}`; }); // sequential, above 100000
- dist[code] = rows.length;
+ const rows = byMat[mat].sort((a, b) => numOf(a) - numOf(b));
+ const start = n;
+ rows.forEach(r => { seqBySku[r.mfr_sku] = `${code}-${n}`; n++; });
+ dist[code] = rows.length; ranges[code] = `${code}-${start} … ${code}-${n - 1}`;
}
for (const r of enr) r.dw_sku = seqBySku[r.mfr_sku];
fs.writeFileSync(ENR, JSON.stringify(enr, null, 2));
@@ -43,7 +47,9 @@ const numOf = r => parseInt((String(r.mfr_sku).match(/\d+/) || ['0'])[0], 10);
await db.end();
fs.writeFileSync(MAPOUT, JSON.stringify(map, null, 2));
- console.log('sequential DW-less SKU series:');
- Object.entries(dist).sort((a, b) => b[1] - a[1]).forEach(([c, v]) => console.log(` ${c}-100001 … ${c}-${100000 + v} (${v})`));
- console.log(`total=${Object.values(dist).reduce((a, b) => a + b, 0)} | map entries=${map.length} | with shopify id=${map.filter(m => m.shopify_product_id).length}`);
+ const nums = Object.values(seqBySku).map(s => parseInt(s.split('-')[1], 10));
+ console.log('unique 6-digit running sequence (grouped by material):');
+ Object.entries(ranges).forEach(([c, r]) => console.log(` ${r} (${dist[c]})`));
+ console.log(`total=${Object.values(dist).reduce((a, b) => a + b, 0)} | number range ${Math.min(...nums)}–${Math.max(...nums)} | unique numbers=${new Set(nums).size}/${nums.length}`);
+ console.log(`map entries=${map.length} | with shopify id=${map.filter(m => m.shopify_product_id).length}`);
})().catch(e => { console.error('ERROR', e.message); process.exit(1); });
← 1df17882 wallquest refresh: port login fix into scrape.cjs (.login-bu
·
back to Designer Wallcoverings
·
Carl Robinson: harden Shopify SKU update — key on product-id 2faa01a5 →