[object Object]

← back to Designerwallcoverings

TK-10484: archived 15 imageless unminted drafts; fix viewer-rebuild (-tA, parse before write)

548133708520eb27e9c30a7394144e5c41f524d5 · 2026-09-24 12:50:56 -0700 · Steve Abrams

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

Files touched

Diff

commit 548133708520eb27e9c30a7394144e5c41f524d5
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Sep 24 12:50:56 2026 -0700

    TK-10484: archived 15 imageless unminted drafts; fix viewer-rebuild (-tA, parse before write)
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---
 scripts/tk10484-archive-noimage.mjs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/scripts/tk10484-archive-noimage.mjs b/scripts/tk10484-archive-noimage.mjs
index f76644f..6c11f71 100644
--- a/scripts/tk10484-archive-noimage.mjs
+++ b/scripts/tk10484-archive-noimage.mjs
@@ -55,9 +55,7 @@ const n = psql(`SELECT count(*) FROM jeffrey_stevens_catalog WHERE archived_at I
 console.log(`APPLIED — ${n} rows archived.`);
 
 // rebuild viewer data.json excluding archived (remaining rows all have real images)
-const json = psql(`\\pset format unaligned
-\\pset tuples_only on
-SELECT json_agg(row_to_json(t)) FROM (
+const json = execFileSync('psql', [...PG, '-tA', '-c', `SELECT json_agg(row_to_json(t)) FROM (
   SELECT sku, dw_sku, COALESCE(NULLIF(name,''),pattern_name) AS title, collection,
          settlement_status, settlement_flag_reason AS reason, settlement_cody_flag AS cody_flag,
          on_shopify, image_url, false AS img_placeholder,
@@ -68,8 +66,8 @@ SELECT json_agg(row_to_json(t)) FROM (
   FROM jeffrey_stevens_catalog
   WHERE settlement_status IS NOT NULL AND archived_at IS NULL
   ORDER BY CASE settlement_status WHEN 'EXCLUDE' THEN 0 WHEN 'REVIEW' THEN 1 ELSE 2 END, reason, title
-) t;`).trim();
+) t;`], { encoding: 'utf8' }).trim();
+const rows = JSON.parse(json); // parse BEFORE writing so a bad payload never clobbers the viewer
 writeFileSync(join(ROOT, 'tmp/settlement-viewer/data.json'), json);
-const rows = JSON.parse(json);
 console.log(`Viewer data.json rebuilt: ${rows.length} rows (archived excluded), all have image: ${rows.every((r) => r.image_url)}`);
 console.log('Undo: node scripts/tk10484-archive-noimage.mjs --rollback');

← e51b1da TK-10484: reversible archiver for 15 imageless unminted JSte  ·  back to Designerwallcoverings  ·  TK-10484: reversible yorkwall cost applier for 47 NU codes ( 78f2d63 →