Fix admin dashboard summary nulls
This commit is contained in:
+19
-2
@@ -229,9 +229,26 @@ export function createLocalUserAuth(pool) {
|
||||
|
||||
async function getAdminSummary() {
|
||||
const [[row]] = await pool.execute(
|
||||
`SELECT COUNT(*) AS total, SUM(CASE WHEN balance_cents < 0 THEN 1 ELSE 0 END) AS lowBalance FROM auth_users`,
|
||||
`SELECT
|
||||
COUNT(*) AS total,
|
||||
SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) AS active,
|
||||
SUM(CASE WHEN balance_cents < 0 THEN 1 ELSE 0 END) AS lowBalance,
|
||||
SUM(balance_cents) AS totalBalanceCents
|
||||
FROM auth_users`,
|
||||
);
|
||||
return { users: { total: Number(row.total ?? 0), lowBalance: Number(row.lowBalance ?? 0) }, routes: { total: 0, active: 0 } };
|
||||
return {
|
||||
users: {
|
||||
total: Number(row.total ?? 0),
|
||||
active: Number(row.active ?? 0),
|
||||
lowBalance: Number(row.lowBalance ?? 0),
|
||||
totalBalanceCents: Number(row.totalBalanceCents ?? 0),
|
||||
},
|
||||
usage24h: { count: 0, costCents: 0 },
|
||||
lowBalanceUsers: [],
|
||||
recentUsage: [],
|
||||
recentLedger: [],
|
||||
llm: { keyCount: 0, selectedKeyName: null, globalModel: null },
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user