Fixes for reset and calculate scripts

This commit is contained in:
2025-01-16 14:21:33 -05:00
parent 7ec587595a
commit c9aefdc756
4 changed files with 195 additions and 255 deletions

View File

@@ -19,7 +19,7 @@ router.get('/', async (req, res) => {
const params = [];
if (search) {
whereConditions.push('(p.vendor LIKE ? OR vm.contact_name LIKE ?)');
whereConditions.push('(p.vendor LIKE ? OR vd.contact_name LIKE ?)');
params.push(`%${search}%`, `%${search}%`);
}
@@ -61,9 +61,9 @@ router.get('/', async (req, res) => {
const [vendors] = await pool.query(`
SELECT
p.vendor as name,
vm.contact_name,
vm.email,
vm.phone,
vd.contact_name,
vd.email,
vd.phone,
vm.status,
vm.avg_lead_time_days,
vm.on_time_delivery_rate,
@@ -72,6 +72,7 @@ router.get('/', async (req, res) => {
COUNT(DISTINCT p.product_id) as active_products
FROM products p
LEFT JOIN vendor_metrics vm ON p.vendor = vm.vendor
LEFT JOIN vendor_details vd ON p.vendor = vd.vendor
${whereClause}
GROUP BY p.vendor
ORDER BY ${sortColumn} ${sortDirection}