-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_agents.js
More file actions
60 lines (53 loc) · 1.93 KB
/
Copy pathtest_agents.js
File metadata and controls
60 lines (53 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const db = require('./db1');
async function testAgents() {
try {
console.log('🔄 Testing EAMVU agents query...');
// Test basic table existence
console.log('1. Testing table existence...');
const tableCheck = await db.query(`
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_name = 'eamvu_agents'
);
`);
console.log(' eamvu_agents table exists:', tableCheck.rows[0].exists);
// Test basic select
console.log('2. Testing basic select...');
const basicResult = await db.query('SELECT COUNT(*) FROM eamvu_agents');
console.log(' Total agents:', basicResult.rows[0].count);
// Test the exact query from the backend
console.log('3. Testing exact backend query...');
const result = await db.query(`
SELECT
ea.agent_id,
ea.name,
ea.email,
ea.phone,
ea.status,
ea.location,
ea.expertise,
ea.max_concurrent_assignments,
COALESCE(
(SELECT COUNT(*) FROM agent_assignments WHERE agent_id = ea.agent_id AND status = 'active'),
0
) as assigned_applications
FROM eamvu_agents ea
WHERE ea.status = 'active'
ORDER BY ea.name
`);
console.log(`✅ Query successful! Found ${result.rows.length} agents:`);
result.rows.forEach(agent => {
console.log(` - ${agent.name} (${agent.agent_id}) - Status: ${agent.status}`);
console.log(` Email: ${agent.email}, Phone: ${agent.phone}`);
console.log(` Location: ${agent.location}, Max assignments: ${agent.max_concurrent_assignments}`);
console.log(` Expertise: ${agent.expertise}, Current assignments: ${agent.assigned_applications}`);
console.log('');
});
} catch (error) {
console.error('❌ Error testing agents:', error.message);
console.error('Full error:', error);
} finally {
process.exit(0);
}
}
testAgents();