chore(账号): 删掉没人调的 refreshUserProblemDisplayIds
Some checks failed
Deploy / deploy (push) Has been cancelled

oj/api.ts 里那句 `// TODO: 这个API有问题` 是从 ojnext 原样搬过来的,**说的是
旧后端的 bug,移植时已经修掉了**。旧的 ProfileProblemDisplayIDRefreshAPI:

    ids = list(acm_problems.keys())
    display_ids = [... filter(id__in=ids, visible=True).values_list("_id")]
    id_map = dict(zip(ids, display_ids))

zip 把「dict 键顺序」和「查询返回顺序」硬凑成对,题目一旦被隐藏或删除
display_ids 就比 ids 短 —— 轻则编号张冠李戴写进库,重则 id_map[k] KeyError。
account.ts 那版是按 id 建 Map、查不到就不动,是对的。留着这条 TODO 只会让
下一个人去查一个不存在的 bug。

顺带查出来:这个函数**两代前端都只有定义、没有任何调用点**。端点清单把
/api/profile/fresh_display_id 标成「前端有调用」是提取脚本匹配到了函数定义
里的 http.get 字面量,不是调用,属于假阳性。前端这个死导出删掉。

后端端点保留 —— 教师改了题目编号之后,学生 acm_problems_status 里缓存的
_id 只有它能刷,是这份缓存唯一的入口。加注释写清它是干嘛的、为什么现在没人
调(要接 UI 从这儿开始)、以及旧后端那版错在哪。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-25 19:02:37 -06:00
parent 9653f1541a
commit 66d51dfd83
2 changed files with 12 additions and 5 deletions

View File

@@ -300,11 +300,6 @@ export function setReaction(problemID: number, type: ReactionKey) {
return api2.post<ReactionState>(`problems/${problemID}/reaction`, { type })
}
// TODO: 这个API有问题
export function refreshUserProblemDisplayIds() {
return api2.post("me/problem-display-ids/refresh")
}
export function getMetrics(userid: number) {
return api2.get<Metrics>(`users/${userid}/metrics`)
}