Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: use .find() for lastUsed instead of filter+sort

ivan_yakimkin33e7167090a7
diff --git a/src/app/(dashboard)/dashboard/api-manager/ApiManagerPageClient.tsx b/src/app/(dashboard)/dashboard/api-manager/ApiManagerPageClient.tsx
index 1635025b97..a71b38a258 100644
--- a/src/app/(dashboard)/dashboard/api-manager/ApiManagerPageClient.tsx
+++ b/src/app/(dashboard)/dashboard/api-manager/ApiManagerPageClient.tsx
@@ -187,17 +187,11 @@ export default function ApiManagerPageClient() {
(entry: any) => entry.apiKeyName === key.name
);
- // Find the most recent call-log for this key to determine lastUsed
- const keyLogs = (logs || []).filter(
+ // The call-logs endpoint returns entries sorted by timestamp DESC,
+ // so the first match is the most recent one.
+ const lastUsed = (logs || []).find(
(log: any) => log.apiKeyName === key.name
- );
- const lastUsed =
- keyLogs.length > 0
- ? keyLogs.sort(
- (a: any, b: any) =>
- new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
- )[0]?.timestamp
- : null;
+ )?.timestamp || null;
stats[key.id] = {
totalRequests: analyticsMatch?.requests ?? 0,