修复 admin 分类 token 查询的 label 运算符优先级
.label("tokens") 只绑到了 sum(output) 而非 input+output 整体,
导致后台显示的分类 token 值偏低。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b8769d8d54
commit
dc5648fbb8
@ -87,8 +87,8 @@ async def list_users(
|
||||
mode_tokens_result = await db.execute(
|
||||
select(
|
||||
ChatLog.mode,
|
||||
func.coalesce(func.sum(ChatLog.tokens_input), 0) +
|
||||
func.coalesce(func.sum(ChatLog.tokens_output), 0).label("tokens")
|
||||
(func.coalesce(func.sum(ChatLog.tokens_input), 0) +
|
||||
func.coalesce(func.sum(ChatLog.tokens_output), 0)).label("tokens")
|
||||
).where(ChatLog.user_id == user.id)
|
||||
.group_by(ChatLog.mode)
|
||||
)
|
||||
@ -147,8 +147,8 @@ async def get_user_detail(
|
||||
mode_tokens_result = await db.execute(
|
||||
select(
|
||||
ChatLog.mode,
|
||||
func.coalesce(func.sum(ChatLog.tokens_input), 0) +
|
||||
func.coalesce(func.sum(ChatLog.tokens_output), 0).label("tokens")
|
||||
(func.coalesce(func.sum(ChatLog.tokens_input), 0) +
|
||||
func.coalesce(func.sum(ChatLog.tokens_output), 0)).label("tokens")
|
||||
).where(ChatLog.user_id == user_id)
|
||||
.group_by(ChatLog.mode)
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user