← back to Dw Sarah Rowland Searchfix
vendor-of-collections.mjs
16 lines
import { gql } from './lib.mjs';
const handles=['barclay-butera-collection-1','candice-olson-collection','candice-olson-collection-1',
'sarah-rowland-wallpaper-collection','kelly-wearstler-collections','the-kelly-wearstler-collection',
'lorenzo-castillo-collection','emma-shipley-wallpaper-collection','paolo-moschino-collections',
'papis-lovejoy','fornasetti','brand-mckenzie-wallpaper-collection','the-graduate-collection',
'steve-abrams-whimsy','hollywood-sunset-collection','the-equestrian-collection','equestrian-collection'];
const Q=`query($h:String!){ collectionByHandle(handle:$h){ title products(first:60){nodes{vendor}} } }`;
for(const h of handles){
const c=(await gql(Q,{h})).collectionByHandle;
if(!c){ console.log(`${h}: (not found)`); continue; }
const hist={}; c.products.nodes.forEach(p=>hist[p.vendor||'∅']=(hist[p.vendor||'∅']||0)+1);
const top=Object.entries(hist).sort((a,b)=>b[1]-a[1]);
const koro=top.find(v=>/koroseal/i.test(v[0]));
console.log(`${koro?'★KOROSEAL':' '} ${c.title.padEnd(42)} vendors: ${top.map(([v,n])=>`${v}:${n}`).join(', ').slice(0,80)}`);
}