← back to Designer Wallcoverings
Strip raw Lillian August color codes from 13 draft LN pattern names
b0437400dce2fee62f2223b1bdbd961e4d754cec · 2026-07-06 16:30:17 -0700 · Steve
Files touched
A scripts/cleanup_ln_rawcodes.js
Diff
commit b0437400dce2fee62f2223b1bdbd961e4d754cec
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Jul 6 16:30:17 2026 -0700
Strip raw Lillian August color codes from 13 draft LN pattern names
---
scripts/cleanup_ln_rawcodes.js | 62 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/scripts/cleanup_ln_rawcodes.js b/scripts/cleanup_ln_rawcodes.js
new file mode 100644
index 00000000..5fbd2b50
--- /dev/null
+++ b/scripts/cleanup_ln_rawcodes.js
@@ -0,0 +1,62 @@
+#!/usr/bin/env node
+/**
+ * Clean raw Lillian August color codes out of draft LN pattern_names.
+ * "Antique Gold 313" → "Antique Gold", "Charcoal & 319" → "Charcoal", "Wicker Rushcloth 294" → "Wicker Rushcloth".
+ * Scope: draft (non-active) LN products whose pattern_name contains a trailing numeric code.
+ * Updates dw_unified pattern_name + Shopify product title. DRY-RUN default; --apply to write.
+ */
+require('dotenv').config({ path: require('path').join(__dirname, '..', '.env') });
+const { Client } = require('pg');
+const SHOP = process.env.SHOPIFY_STORE_DOMAIN;
+const TOKEN = process.env.SHOPIFY_ADMIN_ACCESS_TOKEN || process.env.SHOPIFY_ADMIN_TOKEN;
+const VER = process.env.SHOPIFY_ADMIN_API_VERSION || '2024-01';
+const REST = `https://${SHOP}/admin/api/${VER}`;
+const DBURL = process.env.DATABASE_URL || 'postgresql://stevestudio2@/dw_unified?host=/tmp';
+const APPLY = process.argv.includes('--apply');
+const sleep = (ms) => new Promise(r => setTimeout(r, ms));
+const strip = (p) => p.replace(/\s*&?\s*\d+\s*$/, '').replace(/\s*&\s*$/, '').trim();
+
+async function rest(method, path, body) {
+ for (let a = 0; a < 6; a++) {
+ const res = await fetch(`${REST}${path}`, { method, headers: { 'X-Shopify-Access-Token': TOKEN, 'Content-Type': 'application/json' }, body: body ? JSON.stringify(body) : undefined });
+ if (res.status === 429) { await sleep(2000); continue; }
+ if (!res.ok) throw new Error(`${res.status}: ${(await res.text()).slice(0, 120)}`);
+ return res.json();
+ }
+ throw new Error('429');
+}
+
+(async () => {
+ const db = new Client({ connectionString: DBURL }); await db.connect();
+ // draft LN with a digit in pattern_name (raw code)
+ const { rows } = await db.query(
+ `SELECT dw_sku, shopify_product_id, pattern_name, color_name
+ FROM phillipe_romano_catalog
+ WHERE created_at::date='2026-07-06' AND mfr_sku LIKE 'LN%' AND shopify_product_id IS NOT NULL
+ AND pattern_name ~ '[0-9]' ORDER BY pattern_name`);
+ // confirm each is actually a draft (not active) by checking Shopify status
+ const targets = [];
+ for (const r of rows) {
+ const p = (await rest('GET', `/products/${r.shopify_product_id}.json?fields=id,status,title`)).product;
+ r.status = p.status; r.oldTitle = p.title; r.newPattern = strip(r.pattern_name);
+ r.newTitle = `${r.newPattern} - ${r.color_name} | Phillipe Romano`;
+ if (p.status !== 'active' && r.newPattern !== r.pattern_name) targets.push(r);
+ await sleep(250);
+ }
+ console.log(`${APPLY ? '' : '[DRY-RUN] '}Clean raw-code names — ${targets.length} draft LN products`);
+ console.log('DW_SKU OLD pattern → NEW pattern (status)');
+ for (const r of targets) console.log(` ${r.dw_sku.padEnd(13)} ${r.pattern_name.padEnd(22)} → ${r.newPattern.padEnd(16)} (${r.status})`);
+
+ if (!APPLY) { console.log('\nNO WRITES. --apply to update dw_unified pattern_name + Shopify title.'); await db.end(); return; }
+ console.log('\nApplying…'); let ok = 0;
+ for (const r of targets) {
+ try {
+ await rest('PUT', `/products/${r.shopify_product_id}.json`, { product: { id: Number(r.shopify_product_id), title: r.newTitle } });
+ await db.query(`UPDATE phillipe_romano_catalog SET pattern_name=$1, pl_updated_at=now() WHERE dw_sku=$2`, [r.newPattern, r.dw_sku]);
+ ok++;
+ } catch (e) { console.log(` ✗ ${r.dw_sku}: ${e.message.slice(0, 100)}`); }
+ await sleep(350);
+ }
+ console.log(`Cleaned ${ok}/${targets.length}`);
+ await db.end();
+})().catch(e => { console.error('FATAL', e); process.exit(1); });
← f1d58be7 fix #3: material-SKU scheme downstream — VENDOR_RANGES entri
·
back to Designer Wallcoverings
·
chore: v1.1.6 → v1.1.7 (session close: WallQuest onboard + P 874f3387 →