Files
mcp-vultr/not_used/verify_packages.js

43 lines
1.3 KiB
JavaScript

require('dotenv').config();
const customerDb = require('./services/customerDb');
const mysql = require('mysql2/promise');
async function verify() {
const pool = require('./db_config');
console.log('Verifying Package Item Retrieval...');
// Get 5 random customers who have a service linked
const [rows] = await pool.query(`
SELECT c.name, c.no_wa, c.no_services
FROM customer c
WHERE c.no_services != ''
LIMIT 5
`);
for (const cust of rows) {
console.log(`\nChecking Customer: ${cust.name} (${cust.no_wa})`);
const data = await customerDb.getCustomerByPhone(cust.no_wa);
if (data) {
console.log(`- Service ID: ${data.no_services}`);
console.log(`- Package Name (from package_item): ${data.package_name}`);
console.log(`- Package Price (from package_item): ${data.package_price}`);
} else {
console.log('No data found via getCustomerByPhone');
}
}
// Check direct DB consistency
const [audit] = await pool.query(`
SELECT COUNT(*) as count
FROM customer c
JOIN services s ON c.no_services = s.no_services
JOIN package_item pi ON s.item_id = pi.p_item_id
`);
console.log(`\nTotal customers with valid linked package items: ${audit[0].count}`);
process.exit(0);
}
verify();