mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 00:53:33 +00:00
fix: 修复 Gemini 统计功能的多个问题
主要修复: 1. geminiRoutes.js 主端点现在使用统一调度器(unifiedGeminiScheduler) - 支持模型过滤 - 支持账户调度控制 - 与 Claude 保持一致的调度逻辑 2. 修复 Gemini 账户统计数据获取 - admin 路由现在正确获取 Gemini 账户的使用统计 - 使用 redis.getAccountUsageStats 获取真实数据 - 与 Claude 账户统计逻辑保持一致 这些修复确保了 Gemini 服务的数据统计功能正常工作,包括: - 请求次数统计 - Token 使用量统计 - 模型级别的统计数据 - API Keys 页面和账户管理页面的数据显示 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1423,13 +1423,29 @@ router.get('/gemini-accounts', authenticateAdmin, async (req, res) => {
|
||||
try {
|
||||
const accounts = await geminiAccountService.getAllAccounts();
|
||||
|
||||
// 为Gemini账户添加空的使用统计(暂时)
|
||||
const accountsWithStats = accounts.map(account => ({
|
||||
...account,
|
||||
usage: {
|
||||
daily: { tokens: 0, requests: 0, allTokens: 0 },
|
||||
total: { tokens: 0, requests: 0, allTokens: 0 },
|
||||
averages: { rpm: 0, tpm: 0 }
|
||||
// 为每个账户添加使用统计信息(与Claude账户相同的逻辑)
|
||||
const accountsWithStats = await Promise.all(accounts.map(async (account) => {
|
||||
try {
|
||||
const usageStats = await redis.getAccountUsageStats(account.id);
|
||||
return {
|
||||
...account,
|
||||
usage: {
|
||||
daily: usageStats.daily,
|
||||
total: usageStats.total,
|
||||
averages: usageStats.averages
|
||||
}
|
||||
};
|
||||
} catch (statsError) {
|
||||
logger.warn(`⚠️ Failed to get usage stats for Gemini account ${account.id}:`, statsError.message);
|
||||
// 如果获取统计失败,返回空统计
|
||||
return {
|
||||
...account,
|
||||
usage: {
|
||||
daily: { tokens: 0, requests: 0, allTokens: 0 },
|
||||
total: { tokens: 0, requests: 0, allTokens: 0 },
|
||||
averages: { rpm: 0, tpm: 0 }
|
||||
}
|
||||
};
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user