[object Object]

← back to Designer Wallcoverings

wallquest import rule: no price on a loaded page = discontinued (excludes transient nav/scrape failures)

9c4de69d8afff7f2a3f48f51dfe3d721aaf0f622 · 2026-07-06 15:35:26 -0700 · Steve

Files touched

Diff

commit 9c4de69d8afff7f2a3f48f51dfe3d721aaf0f622
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Jul 6 15:35:26 2026 -0700

    wallquest import rule: no price on a loaded page = discontinued (excludes transient nav/scrape failures)
---
 scripts/wallquest-refresh/write.cjs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/wallquest-refresh/write.cjs b/scripts/wallquest-refresh/write.cjs
index 511d628c..2ae6da6b 100644
--- a/scripts/wallquest-refresh/write.cjs
+++ b/scripts/wallquest-refresh/write.cjs
@@ -9,7 +9,11 @@ const sql=v=>(v==null||v==='')?'NULL':"'"+esc(v)+"'";
 const rows=ls.filter(r=>r.priceValue||(r.specs&&Object.keys(r.specs).length)||(r.imgs&&r.imgs.length)||r.discontinued).map(r=>{
   const price=r.priceValue?parseFloat(String(r.priceValue).replace(/,/g,'')):null;
   const w=(r.specs||{})['Roll Width']||null, len=(r.specs||{})['Roll Length']||null, m=(r.specs||{})['Material']||null, img=(r.imgs||[])[0]||null;
-  const disc=r.discontinued?'true':'false'; // Roll Length carries the per-item unit basis (e.g. "8 yd" bolt vs "11 yd" roll)
+  // Steve's rule: no price on a page that actually LOADED = discontinued (a logged-in trade acct always
+  // has a price on active items). Exclude transient nav/scrape failures so hiccups don't kill live products.
+  const hasRealPrice=r.priceValue && r.priceValue!=='0.00';
+  const loaded=!(r.nav===0) && !r.err;
+  const disc=(r.discontinued || (loaded && !hasRealPrice))?'true':'false'; // Roll Length carries the per-item unit basis (8yd bolt vs 11yd roll)
   return `(${sql(r.sku)},${price==null?'NULL':price},${sql(w)},${sql(len)},${sql(m)},${sql(img)},${disc})`;});
 if(!rows.length){console.log('no rows');process.exit(0);}
 const stmt=`WITH d(sku,price,width,length,material,img,discontinued) AS (VALUES ${rows.join(',')}) UPDATE wallquest_catalog c SET price_retail=COALESCE(NULLIF(d.price,0),c.price_retail),width=COALESCE(d.width,c.width),length=COALESCE(d.length,c.length),material=COALESCE(d.material,c.material),image_url=COALESCE(d.img,c.image_url),discontinued=d.discontinued::boolean,price_updated_at=CURRENT_DATE,specs_scraped_at=now() FROM d WHERE c.mfr_sku=d.sku;`;

← 87ba5cdc Daisy contrarian fixes: strip coordinate-image contamination  ·  back to Designer Wallcoverings  ·  WallQuest->PR: Lillian August 140 live (material titles) + P d1369ad4 →