- 部署: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
@@ -74,12 +74,12 @@ export const lastVisitSchema = z.object({
|
||||
|
||||
/**
|
||||
* 课堂看板里老师布置这节课的题:按输入顺序给展示题号,最多 20 道,空数组 = 清掉。
|
||||
* `language` 是这份作业用什么语言做;不传当 null(上线时还开着的旧看板页面不带它)
|
||||
* `language` 是这份作业用什么语言做,null = 没选
|
||||
*/
|
||||
export const classLessonRequestSchema = z.object({
|
||||
className: z.string().trim().min(1),
|
||||
problemDisplayIds: z.array(z.string().trim().min(1)).max(20),
|
||||
language: lessonLanguageSchema.optional(),
|
||||
language: lessonLanguageSchema.nullable(),
|
||||
})
|
||||
|
||||
export const classBoardProblemSchema = z.object({
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -484,7 +484,7 @@ export const problemListSchema = paginatedSchema(problemListItemSchema)
|
||||
export const problemTypeFilterSchema = z.enum(['sql', 'reference', 'flowchart', 'ast'])
|
||||
|
||||
/**
|
||||
* 题目列表的排序。值沿用原来的(旧链接照样能用):空串 = 最新创建、create_time = 最早创建,
|
||||
* 题目列表的排序:空串 = 最新创建、create_time = 最早创建,
|
||||
* ±submission_number / ±accepted_number 是做过 / 做对的**人数**,带 - 是从多到少
|
||||
*/
|
||||
export const problemListSortSchema = z.enum(['', 'create_time', '-submission_number', 'submission_number', '-accepted_number', 'accepted_number'])
|
||||
|
||||
Reference in new issue
Block a user