fix: 修复排名页跳转用户详情数据为0的问题
排名页使用 display_name(中文名)作为链接参数,但详情查询用 username(英文)过滤,导致 SQL 匹配不到数据全部返回0。 - 排名 API 额外返回 username 字段 - 跳转链接改用 username 作为参数 - 详情 API 返回 display_name 用于页面标题展示
This commit is contained in:
@@ -183,6 +183,7 @@ export async function getUserRanking(
|
||||
return rows.map((r, i) => ({
|
||||
rank: i + 1,
|
||||
name: displayNames[r.user_id] || r.username,
|
||||
username: r.username as string,
|
||||
id: Number(r.user_id),
|
||||
calls: Number(r.calls),
|
||||
prompt_tokens: Number(r.prompt),
|
||||
@@ -308,8 +309,17 @@ export async function getUserDetail(
|
||||
params2
|
||||
);
|
||||
|
||||
const displayNames = await getDisplayNames();
|
||||
const userRow = await query(
|
||||
"SELECT id FROM users WHERE username = $1 LIMIT 1",
|
||||
[username]
|
||||
);
|
||||
const displayName =
|
||||
userRow.length > 0 ? displayNames[userRow[0].id] || username : username;
|
||||
|
||||
const o = overview[0];
|
||||
return {
|
||||
display_name: displayName,
|
||||
calls: Number(o.calls),
|
||||
prompt_tokens: Number(o.prompt),
|
||||
completion_tokens: Number(o.completion),
|
||||
|
||||
Reference in New Issue
Block a user