Revert: 撤销 584fa8c 之后的所有提交

This commit is contained in:
SunSeekerX
2026-01-03 23:24:59 +08:00
parent 74e71d0afc
commit 90023d1551
27 changed files with 219 additions and 488 deletions

View File

@@ -79,8 +79,7 @@ router.get('/api-keys/:keyId/cost-debug', authenticateAdmin, async (req, res) =>
const costStats = await redis.getCostStats(keyId)
const dailyCost = await redis.getDailyCost(keyId)
const today = redis.getDateStringInTimezone()
// eslint-disable-next-line no-unused-vars
const _client = redis.getClientSafe()
const client = redis.getClientSafe()
// 获取所有相关的Redis键
const costKeys = await redis.scanKeys(`usage:cost:*:${keyId}:*`)
@@ -290,18 +289,20 @@ router.get('/api-keys', authenticateAdmin, async (req, res) => {
}
// 为每个API Key添加owner的displayName批量获取优化
const userIdsToFetch = [...new Set(result.items.filter((k) => k.userId).map((k) => k.userId))]
const userIdsToFetch = [
...new Set(result.items.filter((k) => k.userId).map((k) => k.userId))
]
const userMap = new Map()
if (userIdsToFetch.length > 0) {
// 批量获取用户信息
const users = await Promise.all(
userIdsToFetch.map((id) => userService.getUserById(id, false).catch(() => null))
userIdsToFetch.map((id) =>
userService.getUserById(id, false).catch(() => null)
)
)
userIdsToFetch.forEach((id, i) => {
if (users[i]) {
userMap.set(id, users[i])
}
if (users[i]) userMap.set(id, users[i])
})
}