mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
fix(usage): filter totalRequests by selected time period (#857)
The totalRequests on dashboard/usage overview always showed lifetime total instead of respecting the selected period (24h/7d/30d/60d). Now calculated from period-filtered data like other stats. Co-authored-by: Tuan-TC <tuan-tc@users.noreply.github.com>
This commit is contained in:
@@ -533,12 +533,9 @@ export async function getUsageStats(period = "all") {
|
||||
})
|
||||
.slice(0, 20);
|
||||
|
||||
const lifetimeTotalRequests = typeof db.data.totalRequestsLifetime === "number"
|
||||
? db.data.totalRequestsLifetime
|
||||
: history.length;
|
||||
|
||||
// totalRequests: calculated from period-filtered data (not lifetime)
|
||||
const stats = {
|
||||
totalRequests: lifetimeTotalRequests,
|
||||
totalRequests: 0,
|
||||
totalPromptTokens: 0, totalCompletionTokens: 0, totalCost: 0,
|
||||
byProvider: {}, byModel: {}, byAccount: {}, byApiKey: {}, byEndpoint: {},
|
||||
last10Minutes: [],
|
||||
@@ -799,6 +796,9 @@ export async function getUsageStats(period = "all") {
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate totalRequests from period-filtered data (not lifetime)
|
||||
stats.totalRequests = Object.values(stats.byProvider).reduce((sum, p) => sum + (p.requests || 0), 0);
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user