Skip to content

Commit f75715d

Browse files
fix bugggg
1 parent 39ca006 commit f75715d

File tree

6 files changed

+84
-2
lines changed

6 files changed

+84
-2
lines changed

backend/data/careerLibrary.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ function buildCareerRecords() {
169169
const seen = new Set();
170170

171171
function pushRecord(name, category) {
172+
// Explicitly exclude specific roles requested by user
173+
if (name.includes('Giáo viên Toán STEM') || name.includes('Giảng viên Toán đội tuyển')) {
174+
return;
175+
}
176+
172177
const key = `${name}`.toLowerCase();
173178
if (seen.has(key)) return;
174179
seen.add(key);

backend/database/career_advisor.db

0 Bytes
Binary file not shown.

backend/database/career_catalog.db

0 Bytes
Binary file not shown.

backend/routes/debug.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const express = require('express');
2+
const router = express.Router();
3+
const path = require('path');
4+
const sqlite3 = require('sqlite3').verbose();
5+
6+
// ... existing imports ...
7+
8+
// New debug endpoint
9+
router.get('/db-info', (req, res) => {
10+
const dbPath = process.env.CAREER_CATALOG_DB_PATH
11+
|| path.join(__dirname, '..', 'database', 'career_catalog.db');
12+
13+
const db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err) => {
14+
if (err) {
15+
return res.json({
16+
status: 'error',
17+
path: dbPath,
18+
error: err.message
19+
});
20+
}
21+
22+
db.get('SELECT COUNT(*) as count FROM jobs', (err, row) => {
23+
db.get('SELECT * FROM jobs WHERE title LIKE "%Toán STEM%"', (err2, STEMRow) => {
24+
db.close();
25+
res.json({
26+
status: 'ok',
27+
path: dbPath,
28+
resolvedPath: path.resolve(dbPath),
29+
jobCount: row?.count,
30+
hasSTEM: !!STEMRow,
31+
stemExample: STEMRow,
32+
cwd: process.cwd(),
33+
envVar: process.env.CAREER_CATALOG_DB_PATH
34+
});
35+
});
36+
});
37+
});
38+
});
39+
40+
module.exports = router;

backend/scripts/debugDbPath.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const sqlite3 = require('sqlite3').verbose();
4+
const { buildCareerRecords } = require('../data/careerLibrary');
5+
6+
// Check if env var is set
7+
const envDbPath = process.env.CAREER_CATALOG_DB_PATH;
8+
const defaultDbPath = path.join(__dirname, '../database/career_catalog.db');
9+
const dbPath = envDbPath || defaultDbPath;
10+
11+
console.log('🔍 Debugging DB Path...');
12+
console.log(`Msg from script: Env var CAREER_CATALOG_DB_PATH is: ${envDbPath}`);
13+
console.log(`Msg from script: Using DB Path: ${dbPath}`);
14+
15+
const db = new sqlite3.Database(dbPath, (err) => {
16+
if (err) {
17+
console.error('❌ Cannot open DB:', err.message);
18+
return;
19+
}
20+
21+
db.get('SELECT COUNT(*) as count FROM jobs', (err, row) => {
22+
if (err) {
23+
console.error('❌ Error querying jobs:', err.message);
24+
} else {
25+
console.log(`✅ Job count in this DB: ${row.count}`);
26+
}
27+
28+
// Check for specific role
29+
db.get('SELECT * FROM jobs WHERE title LIKE "%Toán STEM%"', (err, row) => {
30+
if (row) {
31+
console.log('⚠️ Found "Giáo viên Toán STEM" in this DB!');
32+
} else {
33+
console.log('✅ "Giáo viên Toán STEM" NOT found in this DB.');
34+
}
35+
db.close();
36+
});
37+
});
38+
});

backend/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ app.use('/api/chat', chatRoutes);
4444
app.use('/api/profile', profileRoutes);
4545
app.use('/api/explore', exploreRoutes);
4646
app.use('/api/chatbot', chatbotRoutes); // NEW: Question-based chatbot
47-
48-
// Health check
47+
app.use('/api/health', require('./routes/debug')); // NEW: Debug info
4948
app.get('/api/health', (req, res) => {
5049
res.json({ status: 'ok', timestamp: new Date().toISOString() });
5150
});

0 commit comments

Comments
 (0)