Files
cannaiq/backend/archive/check-product-prices.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

57 lines
1.7 KiB
TypeScript

import { pool } from './src/db/migrate.js';
async function checkProductPrices() {
const result = await pool.query(`
SELECT
id,
name,
brand,
regular_price,
sale_price,
in_stock,
stock_status
FROM products
WHERE dispensary_id = 112
ORDER BY brand, name
LIMIT 50
`);
console.log('\n' + '='.repeat(100));
console.log('PRODUCTS WITH PRICES');
console.log('='.repeat(100) + '\n');
result.rows.forEach((row, idx) => {
const regularPrice = row.regular_price ? `$${row.regular_price.toFixed(2)}` : 'N/A';
const salePrice = row.sale_price ? `$${row.sale_price.toFixed(2)}` : 'N/A';
const stock = row.in_stock ? (row.stock_status || 'In Stock') : 'Out of Stock';
console.log(`${idx + 1}. ${row.brand} - ${row.name.substring(0, 50)}`);
console.log(` Price: ${regularPrice} | Sale: ${salePrice} | Stock: ${stock}`);
console.log('');
});
console.log('='.repeat(100) + '\n');
// Summary stats
const stats = await pool.query(`
SELECT
COUNT(*) as total_products,
COUNT(regular_price) as products_with_price,
COUNT(sale_price) as products_with_sale,
COUNT(CASE WHEN in_stock THEN 1 END) as in_stock_count
FROM products
WHERE dispensary_id = 112
`);
console.log('SUMMARY:');
console.log(` Total products: ${stats.rows[0].total_products}`);
console.log(` Products with regular price: ${stats.rows[0].products_with_price}`);
console.log(` Products with sale price: ${stats.rows[0].products_with_sale}`);
console.log(` Products in stock: ${stats.rows[0].in_stock_count}`);
console.log('\n');
await pool.end();
}
checkProductPrices().catch(console.error);