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