fix(usage): add missing await on getAdapter() in getRecentLogs

getAdapter() is async; without await, db was a Promise so db.all() threw
and the outer try/catch returned [] silently — usage logs endpoints
(/api/usage/logs, /api/usage/request-logs) always returned empty data.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
fjia
2026-06-17 10:08:36 +07:00
committed by decolua
parent 706e6513c9
commit 4078f36ced

View File

@@ -700,7 +700,7 @@ export async function appendRequestLog() {}
export async function getRecentLogs(limit = 200) {
try {
const db = getAdapter();
const db = await getAdapter();
const rows = db.all(
`SELECT timestamp, provider, model, connectionId, promptTokens, completionTokens, status, tokens FROM usageHistory ORDER BY id DESC LIMIT ?`,
[limit],