fix: 修复服务账户数量少了response账户

This commit is contained in:
shaw
2025-09-20 22:03:43 +08:00
parent 3628bb2b7a
commit 588b181eb9
2 changed files with 63 additions and 1 deletions

View File

@@ -4010,6 +4010,7 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
bedrockAccountsResult, bedrockAccountsResult,
openaiAccounts, openaiAccounts,
ccrAccounts, ccrAccounts,
openaiResponsesAccounts,
todayStats, todayStats,
systemAverages, systemAverages,
realtimeMetrics realtimeMetrics
@@ -4020,8 +4021,9 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
claudeConsoleAccountService.getAllAccounts(), claudeConsoleAccountService.getAllAccounts(),
geminiAccountService.getAllAccounts(), geminiAccountService.getAllAccounts(),
bedrockAccountService.getAllAccounts(), bedrockAccountService.getAllAccounts(),
ccrAccountService.getAllAccounts(),
redis.getAllOpenAIAccounts(), redis.getAllOpenAIAccounts(),
ccrAccountService.getAllAccounts(),
openaiResponsesAccountService.getAllAccounts(true),
redis.getTodayStats(), redis.getTodayStats(),
redis.getSystemAverages(), redis.getSystemAverages(),
redis.getRealtimeSystemMetrics() redis.getRealtimeSystemMetrics()
@@ -4215,6 +4217,39 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
(acc) => acc.rateLimitStatus && acc.rateLimitStatus.isRateLimited (acc) => acc.rateLimitStatus && acc.rateLimitStatus.isRateLimited
).length ).length
// OpenAI-Responses账户统计
// 注意OpenAI-Responses账户的isActive和schedulable也是字符串类型
const normalOpenAIResponsesAccounts = openaiResponsesAccounts.filter(
(acc) =>
(acc.isActive === 'true' ||
acc.isActive === true ||
(!acc.isActive && acc.isActive !== 'false' && acc.isActive !== false)) &&
acc.status !== 'blocked' &&
acc.status !== 'unauthorized' &&
acc.schedulable !== 'false' &&
acc.schedulable !== false &&
!(acc.rateLimitStatus && acc.rateLimitStatus.isRateLimited)
).length
const abnormalOpenAIResponsesAccounts = openaiResponsesAccounts.filter(
(acc) =>
acc.isActive === 'false' ||
acc.isActive === false ||
acc.status === 'blocked' ||
acc.status === 'unauthorized'
).length
const pausedOpenAIResponsesAccounts = openaiResponsesAccounts.filter(
(acc) =>
(acc.schedulable === 'false' || acc.schedulable === false) &&
(acc.isActive === 'true' ||
acc.isActive === true ||
(!acc.isActive && acc.isActive !== 'false' && acc.isActive !== false)) &&
acc.status !== 'blocked' &&
acc.status !== 'unauthorized'
).length
const rateLimitedOpenAIResponsesAccounts = openaiResponsesAccounts.filter(
(acc) => acc.rateLimitStatus && acc.rateLimitStatus.isRateLimited
).length
const dashboard = { const dashboard = {
overview: { overview: {
totalApiKeys: apiKeys.length, totalApiKeys: apiKeys.length,
@@ -4226,6 +4261,7 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
geminiAccounts.length + geminiAccounts.length +
bedrockAccounts.length + bedrockAccounts.length +
openaiAccounts.length + openaiAccounts.length +
openaiResponsesAccounts.length +
ccrAccounts.length, ccrAccounts.length,
normalAccounts: normalAccounts:
normalClaudeAccounts + normalClaudeAccounts +
@@ -4233,6 +4269,7 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
normalGeminiAccounts + normalGeminiAccounts +
normalBedrockAccounts + normalBedrockAccounts +
normalOpenAIAccounts + normalOpenAIAccounts +
normalOpenAIResponsesAccounts +
normalCcrAccounts, normalCcrAccounts,
abnormalAccounts: abnormalAccounts:
abnormalClaudeAccounts + abnormalClaudeAccounts +
@@ -4240,6 +4277,7 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
abnormalGeminiAccounts + abnormalGeminiAccounts +
abnormalBedrockAccounts + abnormalBedrockAccounts +
abnormalOpenAIAccounts + abnormalOpenAIAccounts +
abnormalOpenAIResponsesAccounts +
abnormalCcrAccounts, abnormalCcrAccounts,
pausedAccounts: pausedAccounts:
pausedClaudeAccounts + pausedClaudeAccounts +
@@ -4247,6 +4285,7 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
pausedGeminiAccounts + pausedGeminiAccounts +
pausedBedrockAccounts + pausedBedrockAccounts +
pausedOpenAIAccounts + pausedOpenAIAccounts +
pausedOpenAIResponsesAccounts +
pausedCcrAccounts, pausedCcrAccounts,
rateLimitedAccounts: rateLimitedAccounts:
rateLimitedClaudeAccounts + rateLimitedClaudeAccounts +
@@ -4254,6 +4293,7 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
rateLimitedGeminiAccounts + rateLimitedGeminiAccounts +
rateLimitedBedrockAccounts + rateLimitedBedrockAccounts +
rateLimitedOpenAIAccounts + rateLimitedOpenAIAccounts +
rateLimitedOpenAIResponsesAccounts +
rateLimitedCcrAccounts, rateLimitedCcrAccounts,
// 各平台详细统计 // 各平台详细统计
accountsByPlatform: { accountsByPlatform: {
@@ -4298,6 +4338,13 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
abnormal: abnormalCcrAccounts, abnormal: abnormalCcrAccounts,
paused: pausedCcrAccounts, paused: pausedCcrAccounts,
rateLimited: rateLimitedCcrAccounts rateLimited: rateLimitedCcrAccounts
},
'openai-responses': {
total: openaiResponsesAccounts.length,
normal: normalOpenAIResponsesAccounts,
abnormal: abnormalOpenAIResponsesAccounts,
paused: pausedOpenAIResponsesAccounts,
rateLimited: rateLimitedOpenAIResponsesAccounts
} }
}, },
// 保留旧字段以兼容 // 保留旧字段以兼容
@@ -4307,6 +4354,7 @@ router.get('/dashboard', authenticateAdmin, async (req, res) => {
normalGeminiAccounts + normalGeminiAccounts +
normalBedrockAccounts + normalBedrockAccounts +
normalOpenAIAccounts + normalOpenAIAccounts +
normalOpenAIResponsesAccounts +
normalCcrAccounts, normalCcrAccounts,
totalClaudeAccounts: claudeAccounts.length + claudeConsoleAccounts.length, totalClaudeAccounts: claudeAccounts.length + claudeConsoleAccounts.length,
activeClaudeAccounts: normalClaudeAccounts + normalClaudeConsoleAccounts, activeClaudeAccounts: normalClaudeAccounts + normalClaudeConsoleAccounts,

View File

@@ -119,6 +119,20 @@
dashboardData.accountsByPlatform.azure_openai.total dashboardData.accountsByPlatform.azure_openai.total
}}</span> }}</span>
</div> </div>
<!-- OpenAI-Responses账户 -->
<div
v-if="
dashboardData.accountsByPlatform['openai-responses'] &&
dashboardData.accountsByPlatform['openai-responses'].total > 0
"
class="inline-flex items-center gap-0.5"
:title="`OpenAI Responses: ${dashboardData.accountsByPlatform['openai-responses'].total} 个 (正常: ${dashboardData.accountsByPlatform['openai-responses'].normal})`"
>
<i class="fas fa-server text-xs text-cyan-600" />
<span class="text-xs font-medium text-gray-700 dark:text-gray-300">{{
dashboardData.accountsByPlatform['openai-responses'].total
}}</span>
</div>
</div> </div>
</div> </div>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400"> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">