Files
cannaiq/backend/check-treez-data.ts
2025-11-28 19:45:44 -07:00

53 lines
1.3 KiB
TypeScript

import { pool } from './src/db/migrate.js';
async function main() {
try {
// Count total products and unique brands
const stats = await pool.query(`
SELECT
COUNT(*) as total_products,
COUNT(DISTINCT brand) as unique_brands
FROM products
WHERE dispensary_id = 149
`);
console.log('Stats:', stats.rows[0]);
// Get sample products to verify brand extraction
const samples = await pool.query(`
SELECT brand, name, variant, dutchie_url
FROM products
WHERE dispensary_id = 149
ORDER BY RANDOM()
LIMIT 10
`);
console.log('\nSample products:');
samples.rows.forEach(row => {
console.log(`Brand: "${row.brand}" | Name: "${row.name}" | Variant: "${row.variant}"`);
});
// Get brand distribution
const brands = await pool.query(`
SELECT brand, COUNT(*) as count
FROM products
WHERE dispensary_id = 149
GROUP BY brand
ORDER BY count DESC
LIMIT 15
`);
console.log('\nTop brands:');
brands.rows.forEach(row => {
console.log(`${row.brand}: ${row.count} products`);
});
} catch (error: any) {
console.error('Error:', error.message);
} finally {
await pool.end();
}
}
main().catch(console.error);