- 部署:JUDGE_STATE_DIR 不再强制设;删掉搬库脚本和只为搬库存在的自检、提醒 - 语言:Python3 / Python2 别名表删掉,normalizeLanguage 改名 parseLanguage - 旧链接:后台题单详情的跳转、用户列表 -last_login 的转换 - 旧页面:布置作业必须带 language(null = 没选);不再清旧版出题页草稿 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e074f3ab8
commit
8427475337
23 files changed
+47
-386
No files matched your search
@@ -18,9 +18,7 @@ import { z } from 'zod'
|
||||
* `apps/api/src/judge/languages.ts` 顶部。
|
||||
*
|
||||
* `Python2` / `Python3` 这两个旧值**已经不在这里了** —— 0019 迁移把库里的
|
||||
* 104530 条提交、937 道题、1235 个用户的成就指标全并成了 `Python`。万一还有旧值
|
||||
* 从别处冒出来(旧客户端的 localStorage、迁移之前排进队列的任务),走下面的
|
||||
* `normalizeLanguage()`,别直接 parse。
|
||||
* 104530 条提交、937 道题、1235 个用户的成就指标全并成了 `Python`。
|
||||
*/
|
||||
export const judgeLanguageSchema = z.enum(['C', 'C++', 'Python', 'Java', 'JavaScript', 'Golang'])
|
||||
|
||||
@@ -62,23 +60,7 @@ export type LessonLanguage = z.infer<typeof lessonLanguageSchema>
|
||||
export type RunnableLanguage = z.infer<typeof runnableLanguageSchema>
|
||||
export type ProblemLanguage = z.infer<typeof problemLanguageSchema>
|
||||
|
||||
/**
|
||||
* 旧语言名 → 现在的值。**库里已经没有旧值了**(0019 迁移清干净并核对过),
|
||||
* 这张表挡的是数据之外的三条路:
|
||||
*
|
||||
* 1. 学生浏览器 localStorage 里存着上次选的 `Python3`(上线那一刻还在那儿);
|
||||
* 2. 迁移之前就排进 BullMQ 的判题任务;
|
||||
* 3. 万一要回滚 —— 旧版后端读 `Python` 会查不到配置,所以**回滚必须连数据一起回**,
|
||||
* 别只滚代码。
|
||||
*/
|
||||
const LANGUAGE_ALIASES: Record<string, ProblemLanguage> = {
|
||||
Python2: 'Python',
|
||||
Python3: 'Python',
|
||||
}
|
||||
|
||||
/** 把可能是旧值的语言名归一化;认不出来返回 null,由调用方决定怎么兜底。 */
|
||||
export function normalizeLanguage(value: unknown): ProblemLanguage | null {
|
||||
if (typeof value !== 'string') return null
|
||||
const parsed = problemLanguageSchema.safeParse(LANGUAGE_ALIASES[value] ?? value)
|
||||
return parsed.success ? parsed.data : null
|
||||
/** 认语言名(地址栏、localStorage 里来的);认不出来返回 null,由调用方决定怎么兜底。 */
|
||||
export function parseLanguage(value: unknown): ProblemLanguage | null {
|
||||
return problemLanguageSchema.safeParse(value).data ?? null
|
||||
}
|
||||
Reference in new issue
Block a user