- 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>
73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
import { pool } from './src/db/migrate.js';
|
|
|
|
async function checkProductData() {
|
|
// Get a few recently saved products
|
|
const result = await pool.query(`
|
|
SELECT
|
|
slug,
|
|
name,
|
|
brand,
|
|
variant,
|
|
regular_price,
|
|
sale_price,
|
|
thc_percentage,
|
|
cbd_percentage,
|
|
strain_type,
|
|
in_stock,
|
|
stock_status,
|
|
image_url
|
|
FROM products
|
|
WHERE dispensary_id = 112
|
|
AND brand IN ('(the) Essence', 'Abundant Organics', 'AAchieve', 'Alien Labs')
|
|
ORDER BY updated_at DESC
|
|
LIMIT 10
|
|
`);
|
|
|
|
console.log('\n📊 Recently Saved Products:');
|
|
console.log('='.repeat(100));
|
|
|
|
result.rows.forEach((row, idx) => {
|
|
console.log(`\n${idx + 1}. ${row.name} (${row.brand})`);
|
|
console.log(` Variant: ${row.variant || 'N/A'}`);
|
|
console.log(` Regular Price: $${row.regular_price || 'N/A'}`);
|
|
console.log(` Sale Price: $${row.sale_price || 'N/A'}`);
|
|
console.log(` THC %: ${row.thc_percentage || 'N/A'}%`);
|
|
console.log(` CBD %: ${row.cbd_percentage || 'N/A'}%`);
|
|
console.log(` Strain: ${row.strain_type || 'N/A'}`);
|
|
console.log(` Stock: ${row.stock_status || (row.in_stock ? 'In stock' : 'Out of stock')}`);
|
|
console.log(` Image: ${row.image_url ? '✓' : 'N/A'}`);
|
|
});
|
|
|
|
console.log('\n' + '='.repeat(100));
|
|
|
|
// Count how many products have complete data
|
|
const stats = await pool.query(`
|
|
SELECT
|
|
COUNT(*) as total,
|
|
COUNT(regular_price) as has_price,
|
|
COUNT(thc_percentage) as has_thc,
|
|
COUNT(cbd_percentage) as has_cbd,
|
|
COUNT(variant) as has_variant,
|
|
COUNT(strain_type) as has_strain,
|
|
COUNT(image_url) as has_image
|
|
FROM products
|
|
WHERE dispensary_id = 112
|
|
AND brand IN ('(the) Essence', 'Abundant Organics', 'AAchieve', 'Alien Labs')
|
|
`);
|
|
|
|
const stat = stats.rows[0];
|
|
console.log('\n📈 Data Completeness for Recently Scraped Brands:');
|
|
console.log(` Total products: ${stat.total}`);
|
|
console.log(` Has price: ${stat.has_price} (${Math.round(stat.has_price / stat.total * 100)}%)`);
|
|
console.log(` Has THC%: ${stat.has_thc} (${Math.round(stat.has_thc / stat.total * 100)}%)`);
|
|
console.log(` Has CBD%: ${stat.has_cbd} (${Math.round(stat.has_cbd / stat.total * 100)}%)`);
|
|
console.log(` Has variant: ${stat.has_variant} (${Math.round(stat.has_variant / stat.total * 100)}%)`);
|
|
console.log(` Has strain type: ${stat.has_strain} (${Math.round(stat.has_strain / stat.total * 100)}%)`);
|
|
console.log(` Has image: ${stat.has_image} (${Math.round(stat.has_image / stat.total * 100)}%)`);
|
|
console.log('');
|
|
|
|
await pool.end();
|
|
}
|
|
|
|
checkProductData().catch(console.error);
|