fix: query UseCaseGen DBs for real user counts in dashboard
This commit is contained in:
parent
205561ccd8
commit
5e000f2aa3
1 changed files with 19 additions and 1 deletions
20
server.js
20
server.js
|
|
@ -809,8 +809,26 @@ function normalizeStats(systemId, raw) {
|
|||
};
|
||||
}
|
||||
if (systemId.includes('usecasegen')) {
|
||||
// Query actual DB for user count (session counters reset on restart)
|
||||
let dbUsers = 0;
|
||||
try {
|
||||
const Database = require('better-sqlite3');
|
||||
if (systemId === 'eco-usecasegen') {
|
||||
const db = new Database('/var/www/eco-usecasegen/data/users.db', { readonly: true });
|
||||
dbUsers = db.prepare('SELECT COUNT(*) as count FROM users').get()?.count || 0;
|
||||
db.close();
|
||||
} else if (systemId === 'ggl-usecasegen') {
|
||||
const db = new Database('/var/www/ggl-usecasegen/data/users.db', { readonly: true });
|
||||
dbUsers = db.prepare('SELECT COUNT(*) as count FROM users').get()?.count || 0;
|
||||
db.close();
|
||||
} else if (systemId === 'fdx-usecasegen') {
|
||||
const db = new Database('/var/www/fedex-cohort-app/data/users.db', { readonly: true });
|
||||
dbUsers = db.prepare('SELECT COUNT(*) as count FROM users').get()?.count || 0;
|
||||
db.close();
|
||||
}
|
||||
} catch (e) { /* fallback to raw */ }
|
||||
return {
|
||||
totalUsers: raw.totalUsers || raw.userCount || 0,
|
||||
totalUsers: dbUsers || raw.totalUsers || raw.userCount || 0,
|
||||
activeToday: raw.activeToday || 0,
|
||||
totalSessions: raw.totalSessions || raw.sessionCount || 0,
|
||||
totalCost: raw.totalCost || raw.estimatedCost || 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue