mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix: usage stats issue
This commit is contained in:
@@ -294,8 +294,8 @@ router.get('/usage-stats', authenticateUser, async (req, res) => {
|
||||
try {
|
||||
const { period = 'week', model } = req.query
|
||||
|
||||
// 获取用户的API Keys
|
||||
const userApiKeys = await apiKeyService.getUserApiKeys(req.user.id)
|
||||
// 获取用户的API Keys (including deleted ones for complete usage stats)
|
||||
const userApiKeys = await apiKeyService.getUserApiKeys(req.user.id, true)
|
||||
const apiKeyIds = userApiKeys.map((key) => key.id)
|
||||
|
||||
if (apiKeyIds.length === 0) {
|
||||
|
||||
@@ -298,10 +298,20 @@
|
||||
<span
|
||||
:class="[
|
||||
'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
|
||||
apiKey.isActive ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'
|
||||
apiKey.isDeleted === 'true' || apiKey.deletedAt
|
||||
? 'bg-gray-100 text-gray-800'
|
||||
: apiKey.isActive
|
||||
? 'bg-green-100 text-green-800'
|
||||
: 'bg-red-100 text-red-800'
|
||||
]"
|
||||
>
|
||||
{{ apiKey.isActive ? 'Active' : 'Disabled' }}
|
||||
{{
|
||||
apiKey.isDeleted === 'true' || apiKey.deletedAt
|
||||
? 'Deleted'
|
||||
: apiKey.isActive
|
||||
? 'Active'
|
||||
: 'Disabled'
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -364,7 +374,7 @@ const loadUsageStats = async () => {
|
||||
try {
|
||||
const [stats, apiKeys] = await Promise.all([
|
||||
userStore.getUserUsageStats({ period: selectedPeriod.value }),
|
||||
userStore.getUserApiKeys()
|
||||
userStore.getUserApiKeys(true) // Include deleted keys
|
||||
])
|
||||
|
||||
usageStats.value = stats
|
||||
|
||||
Reference in New Issue
Block a user