-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-test-reports-db.js
More file actions
56 lines (49 loc) · 1.39 KB
/
Copy pathcheck-test-reports-db.js
File metadata and controls
56 lines (49 loc) · 1.39 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
require('dotenv').config();
const { Pool } = require('pg');
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false }
});
async function checkTestReports() {
const client = await pool.connect();
try {
console.log('📊 Checking test_reports table...\n');
const result = await client.query(`
SELECT
tr.id,
tr.class_id,
tr.section_id,
c.name as class_name,
s.name as section_name,
tr.report_date,
tr.file_name,
tr.file_type,
tr.created_at
FROM test_reports tr
LEFT JOIN classes c ON tr.class_id = c.id
LEFT JOIN sections s ON tr.section_id = s.id
ORDER BY tr.created_at DESC
LIMIT 10
`);
if (result.rows.length === 0) {
console.log('❌ No test reports found in database');
} else {
console.log(`✅ Found ${result.rows.length} test reports:\n`);
console.table(result.rows.map(r => ({
ID: r.id,
Class: r.class_name,
Section: r.section_name,
Date: new Date(r.report_date).toLocaleDateString(),
File: r.file_name,
Type: r.file_type,
Uploaded: new Date(r.created_at).toLocaleString()
})));
}
} catch (error) {
console.error('❌ Error:', error.message);
} finally {
client.release();
await pool.end();
}
}
checkTestReports();