← back to Hollywood Import
verify.js
37 lines
'use strict';
const { spawnSync } = require('child_process');
const { scrubMomentum, leakCheck } = require('./scrub-momentum');
const PSQL = '/opt/homebrew/opt/postgresql@14/bin/psql';
// Pull every hollywood row that carries 'momentum' anywhere (specs or image_url)
const sql = `SELECT json_agg(t) FROM (
SELECT id, pattern_name, color_name, collection, dw_sku, mfr_sku, image_url, specs
FROM vendor_catalog
WHERE vendor_code='hollywood' AND (specs::text ILIKE '%momentum%' OR specs::text ILIKE '%versa%')
) t`;
const r = spawnSync(PSQL, ['-U','stevestudio2','-d','dw_unified','-tA','-c',sql], {encoding:'utf8', maxBuffer:1<<30});
const rows = JSON.parse(r.stdout || '[]') || [];
let leaky = 0; const samples = [];
for (const row of rows) {
const pub = scrubMomentum(row);
const leaks = leakCheck(pub);
if (leaks.length) { leaky++; if (samples.length < 5) samples.push({ id: row.id, leaks, vendor: pub.vendor, title: pub.title }); }
}
console.log(`rows scrubbed: ${rows.length}`);
console.log(`rows with surviving momentum/versa leak (target 0): ${leaky}`);
if (samples.length) { console.log('LEAK SAMPLES:'); samples.forEach(s=>console.log(' ', JSON.stringify(s))); }
// show one full before/after so we can eyeball the scrub
if (rows.length) {
const ex = rows.find(x => (x.specs && JSON.stringify(x.specs).match(/versa/i))) || rows[0];
const pub = scrubMomentum(ex);
console.log('\nSAMPLE SCRUB (id '+ex.id+'):');
console.log(' vendor :', pub.vendor);
console.log(' title :', pub.title);
console.log(' collection :', pub.collection);
console.log(' sku :', pub.sku);
console.log(' imageSrc :', (pub.imageSrc||'').slice(0,55), '(transient → Shopify rehosts)');
console.log(' specs.grade_collection kept?:', pub.specs.grade_collection, '(should be undefined)');
console.log(' specs.real_vendor kept? :', pub.specs.real_vendor, '(should be undefined)');
console.log(' specs.sustainability :', (pub.specs.sustainability||'').slice(0,70));
console.log(' tags :', pub.tags.join(' | ').slice(0,90));
}