Files
cannaiq/backend/archive/check-brands.ts
Kelly d91c55a344 feat: Add stale process monitor, users route, landing page, archive old scripts
- Add backend stale process monitoring API (/api/stale-processes)
- Add users management route
- Add frontend landing page and stale process monitor UI on /scraper-tools
- Move old development scripts to backend/archive/
- Update frontend build with new features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 04:07:31 -07:00

56 lines
1.4 KiB
TypeScript

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();