[object Object]

← back to Designer Wallcoverings

cadence: fix ACTIVE/DRAFT summary count for sample-only products (activatedCount)

eb9c513f63eb0fee21655cbe899ddaba9ae04dde · 2026-06-23 17:16:27 -0700 · Steve

Files touched

Diff

commit eb9c513f63eb0fee21655cbe899ddaba9ae04dde
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Jun 23 17:16:27 2026 -0700

    cadence: fix ACTIVE/DRAFT summary count for sample-only products (activatedCount)
---
 shopify/scripts/cadence/cadence-import.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/shopify/scripts/cadence/cadence-import.js b/shopify/scripts/cadence/cadence-import.js
index 877e50e3..51b31f68 100644
--- a/shopify/scripts/cadence/cadence-import.js
+++ b/shopify/scripts/cadence/cadence-import.js
@@ -641,7 +641,7 @@ if (require.main === module) (async () => {
   for (let i=0;i<picks;i++) picked.push(ready[(start+i)%ready.length]);
   console.log(`\n=== ${COMMIT?'LIVE COMMIT':'DRY-RUN'} — slot ${SLOT}: lead=${ready[start].vendor} · ${picked.length}/${ready.length} READY vendor(s) × up to ${SKUS_PER_VENDOR} SKUs (cursor idx ${cur.idx}→${(start+picked.length)%ready.length}) ===`);
 
-  const plan = []; let created=0, failed=0, linked=0; const activatedSkus=[]; const publishedProductIds=[]; let hitMax=false, hitCap=false;
+  const plan = []; let created=0, failed=0, linked=0, activatedCount=0; const activatedSkus=[]; const publishedProductIds=[]; let hitMax=false, hitCap=false;
   if (MAX_PRODUCTS) console.log(`(--max ${MAX_PRODUCTS} products this run)${ACTIVATE?'  --activate: readiness-passing → ACTIVE + inventory 2026':''}`);
   for (const r of picked) {
     if (hitMax || hitCap) break;
@@ -661,7 +661,7 @@ if (require.main === module) (async () => {
       }
       const res = await createProduct(r.cfg.table, row, payload);
       if (res.ok && res.action === 'linked-existing') { linked++; console.log(`  ↪ ${row.dw_sku} already on Shopify (${res.status}) → backfilled link ${String(res.pid).replace(/.*\//,'')}, skipped create (dedup guard)`); }
-      else if (res.ok) { created++; if (res.activated && res.skus) activatedSkus.push(...res.skus); if (res.published && res.pid) publishedProductIds.push(res.pid); if(created%10===0) process.stdout.write(`\r  created ${created}…`); }
+      else if (res.ok) { created++; if (res.activated) activatedCount++; if (res.activated && res.skus) activatedSkus.push(...res.skus); if (res.published && res.pid) publishedProductIds.push(res.pid); if(created%10===0) process.stdout.write(`\r  created ${created}…`); }
       else { failed++; console.log(`  ✗ ${row.dw_sku} ${JSON.stringify(res.err).slice(0,140)}`); }
       if (res.stop) { console.log(`\n⛔ DAILY_VARIANT_LIMIT reached — stopping (resets in ~24h). created ${created} this run.`); hitCap=true; break; }
       if (MAX_PRODUCTS && (created + linked) >= MAX_PRODUCTS) { console.log(`\n· --max ${MAX_PRODUCTS} reached — stopping this slot (resumes next slot via cursor).`); hitMax=true; break; }
@@ -690,7 +690,9 @@ if (require.main === module) (async () => {
   saveCursor({ idx: (start + picked.length) % ready.length, lastSlot: SLOT, lastRun: TODAY });
   const planFile = path.join(DATADIR, `cadence-plan-${SLOT}-${TODAY}.json`);
   fs.mkdirSync(DATADIR,{recursive:true}); fs.writeFileSync(planFile, JSON.stringify(plan,null,1));
-  const activatedN = activatedSkus.length / 2;
+  // activatedCount counts every product that went ACTIVE (incl. sample-only, whose untracked
+  // sample returns no inventory skus — so it can't be derived from activatedSkus.length/2).
+  const activatedN = activatedCount;
   console.log(`\n\n${COMMIT?`CREATED ${created} (${ACTIVATE?activatedN+' ACTIVE / '+(created-activatedN)+' DRAFT':'all DRAFT'}), linked-existing ${linked} (dedup guard), failed ${failed}`:`DRY-RUN planned ${plan.length} products${ACTIVATE?` (${plan.filter(p=>p.willActivate).length} would activate)`:''}`} → ${planFile}`);
   if (COMMIT) console.log(`restore map: ${RESTORE_FILE} (batch ${BATCH_ID})`);
   if (!COMMIT) {

← 6a487a9d cadence: add sampleOnly vendor mode for Quadrille-house $4.2  ·  back to Designer Wallcoverings  ·  cadence: gate Quadrille-house sample-only drip OFF by defaul 9ec5d21e →