import pg from 'pg'; const { Pool } = pg; const pool = new Pool({ connectionString: process.env.DATABASE_URL }); async function checkBrands() { try { // Get dispensary info const dispensaryResult = await pool.query( "SELECT id, name FROM dispensaries WHERE dutchie_slug = 'AZ-Deeply-Rooted'" ); if (dispensaryResult.rows.length === 0) { console.log('Dispensary not found'); return; } const dispensary = dispensaryResult.rows[0]; console.log(`Dispensary: ${dispensary.name} (ID: ${dispensary.id})`); // Get brand count const brandCountResult = await pool.query( `SELECT COUNT(DISTINCT brand) as brand_count FROM products WHERE dispensary_id = $1 AND brand IS NOT NULL AND brand != ''`, [dispensary.id] ); console.log(`\nTotal distinct brands: ${brandCountResult.rows[0].brand_count}`); // List all brands const brandsResult = await pool.query( `SELECT DISTINCT brand, COUNT(*) as product_count FROM products WHERE dispensary_id = $1 AND brand IS NOT NULL AND brand != '' GROUP BY brand ORDER BY brand`, [dispensary.id] ); console.log(`\nBrands found:`); brandsResult.rows.forEach(row => { console.log(` - ${row.brand} (${row.product_count} products)`); }); } catch (error) { console.error('Error:', error); } finally { await pool.end(); } } checkBrands();