[object Object]

← back to Designerwallcoverings

TK-10484: reversible archiver for 33 yorkwall no-price NU codes (gated, not fired)

41b4348876cfd1aae3f71ad68e7cd32267eeb232 · 2026-09-24 13:08:00 -0700 · Steve Abrams

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 41b4348876cfd1aae3f71ad68e7cd32267eeb232
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Sep 24 13:08:00 2026 -0700

    TK-10484: reversible archiver for 33 yorkwall no-price NU codes (gated, not fired)
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---
 scripts/tk10484-archive-yorkwall-noprice.mjs | 77 ++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/scripts/tk10484-archive-yorkwall-noprice.mjs b/scripts/tk10484-archive-yorkwall-noprice.mjs
new file mode 100644
index 0000000..9d71324
--- /dev/null
+++ b/scripts/tk10484-archive-yorkwall-noprice.mjs
@@ -0,0 +1,77 @@
+#!/usr/bin/env node
+// TK-10484 — archive 33 NU codes with no price on Yorkwall (discontinued/out-of-catalog)
+// Reads ~/yw-cost-results.json, identifies no-price entries, and flags them archived.
+// Fully reversible via --rollback (clears archived_at/reason for these SKUs only).
+//
+//   node scripts/tk10484-archive-yorkwall-noprice.mjs            # dry-run
+//   node scripts/tk10484-archive-yorkwall-noprice.mjs --apply    # archive the 33
+//   node scripts/tk10484-archive-yorkwall-noprice.mjs --rollback # un-archive
+
+import { execFileSync } from 'node:child_process';
+import { readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { dirname, join } from 'node:path';
+import { homedir } from 'node:os';
+
+const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
+const RESULTS_FILE = join(homedir(), 'yw-cost-results.json');
+const PG = ['-h', '/tmp', '-d', 'dw_unified'];
+const mode = process.argv.includes('--apply') ? 'apply'
+           : process.argv.includes('--rollback') ? 'rollback' : 'dry';
+
+const psql = (sql) => execFileSync('psql', [...PG, '-v', 'ON_ERROR_STOP=1', '-c', sql], { encoding: 'utf8' });
+
+console.log(`TK-10484 archive-yorkwall-noprice — mode: ${mode}`);
+
+let results = { results: [] };
+try {
+  results = JSON.parse(readFileSync(RESULTS_FILE, 'utf8'));
+} catch (e) {
+  console.log(`ERROR: could not read ${RESULTS_FILE}: ${e.message}`);
+  process.exit(1);
+}
+
+const noprice = results.results.filter((r) => !r.net || r.net <= 0);
+console.log(`Found: ${noprice.length} no-price codes`);
+
+if (mode === 'dry') {
+  console.log('\nDRY-RUN — would archive these 33 codes via recovered_mfr_code:');
+  console.log(noprice.map((r) => `  ${r.orig} (${r.name?.slice(0, 40) || '?'})`).join('\n'));
+  console.log('\nArchive reason: "yorkwall_noprice; Steve 2026-09-24 (out-of-catalog/discontinued)"');
+  console.log('\nTo apply: node scripts/tk10484-archive-yorkwall-noprice.mjs --apply');
+  process.exit(0);
+}
+
+if (mode === 'rollback') {
+  const codes = noprice.map((r) => `'${r.orig.replace(/'/g, "''")}'`).join(',');
+  if (codes) {
+    psql(`UPDATE jeffrey_stevens_catalog SET archived_at=NULL, archived_reason=NULL WHERE recovered_mfr_code IN (${codes}) AND archived_reason LIKE '%yorkwall_noprice%';`);
+  }
+  console.log(`ROLLBACK done — ${noprice.length} no-price NU codes un-archived.`);
+  process.exit(0);
+}
+
+// apply
+const codes = noprice.map((r) => `'${r.orig.replace(/'/g, "''")}'`).join(',');
+if (!codes) {
+  console.log('ERROR: no no-price codes found');
+  process.exit(1);
+}
+
+psql(`BEGIN;
+ALTER TABLE jeffrey_stevens_catalog
+  ADD COLUMN IF NOT EXISTS archived_at timestamptz,
+  ADD COLUMN IF NOT EXISTS archived_reason text;
+UPDATE jeffrey_stevens_catalog
+  SET archived_at=now(),
+      archived_reason='yorkwall_noprice; Steve 2026-09-24 (out-of-catalog/discontinued/unavailable on yorkwall)'
+  WHERE recovered_mfr_code IN (${codes}) AND archived_at IS NULL;
+COMMIT;`);
+
+const n = psql(`SELECT count(*) FROM jeffrey_stevens_catalog WHERE recovered_mfr_code IN (${codes}) AND archived_at IS NOT NULL;`).trim().match(/^\s*(\d+)/)?.[1] || '0';
+console.log(`APPLIED — ${n} no-price NU codes archived (expected ${noprice.length}).`);
+if (Number(n) !== noprice.length) {
+  console.log('WARNING: count mismatch — investigate.');
+  process.exit(3);
+}
+console.log('Undo: node scripts/tk10484-archive-yorkwall-noprice.mjs --rollback');

← df48217 TK-10484: fix yorkwall cost applier — key on recovered_mfr_c  ·  back to Designerwallcoverings  ·  TK-10484: archived 33 yorkwall no-price NU rows; fix count p 6d77d92 →