57 lines
1.7 KiB
TypeScript
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);
|