From 6b7d87d6778fa01dffd8e901d3be6d14219fc37b Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 12 Oct 2026 21:25:51 +0800 Subject: [PATCH] =?UTF-8?q?chore(=E6=B5=81=E7=A8=8B=E5=9B=BE):=20=E5=88=A0?= =?UTF-8?q?=E6=8E=89=E5=89=8D=E7=AB=AF=E4=B8=A4=E5=91=A8=E5=89=8D=E5=B0=B1?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E8=B0=83=E7=9A=84=20flowchart/current?= =?UTF-8?q?=E3=80=81history=20=E4=B8=A4=E4=B8=AA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 9-28 题目页重构后结果页签只用 scores + GET /flowcharts/:id,这两个留着是给上线那一刻 还开着旧页面的浏览器,现在可以删了,契约里对应的两份形状一起删。 Co-Authored-By: Claude Opus 5.5 --- apps/api/src/routes/flowchart.ts | 47 +++--------------------------- packages/contract/src/flowchart.ts | 12 -------- 2 files changed, 4 insertions(+), 55 deletions(-) diff --git a/apps/api/src/routes/flowchart.ts b/apps/api/src/routes/flowchart.ts index 039f8ec..eadd4ee 100644 --- a/apps/api/src/routes/flowchart.ts +++ b/apps/api/src/routes/flowchart.ts @@ -4,8 +4,6 @@ import { createFlowchartRequestSchema, isFlowchartPass, type CreateFlowchartResponse, - type FlowchartCurrent, - type FlowchartDetail, type FlowchartScores, type FlowchartList, type FlowchartListItem, @@ -777,10 +775,10 @@ flowchartRoutes.post("/flowcharts/:id/retry", requireAuth, async (c) => { /** * 自己在这道题上评完的每一次,按时间从早到晚,已经滤掉加入题单之前的(题单闸门)。 - * current / history / scores 三个接口都从这一份出。 + * 结果页签的历次分数(scores)从这一份出。 * * 只取分数和闸门要的几列:整行带着画布 JSON 和 mermaid 源码(一条约 5KB),画了几十次 - * 的学生每切一次题就要搬几百 KB,而结果页签只要分数。要整行的 history 自己按 id 再取。 + * 的学生每切一次题就要搬几百 KB,而结果页签只要分数。 * userId / problemId / createTime 三列是 hiddenByProblemSet 要的,别删。 */ async function myEvaluatedFlowcharts(user: AuthUser, problemId: number) { @@ -809,46 +807,9 @@ async function myEvaluatedFlowcharts(user: AuthUser, problemId: number) { return { visible, hidden: rows.length - visible.length } } -/* - * current / history:前端从 2026-09-28 起改用下面的 scores + GET /flowcharts/:id,不再调这两个。 - * 先留着给上线那一刻还开着旧页面的浏览器(机房里一节课都不刷新是常态),下一次清理时删掉, - * 连同契约里的 flowchartCurrentSchema / flowchartDetailSchema。 - */ -flowchartRoutes.get("/problems/:id/flowchart/current", requireAuth, async (c) => { - const problemId = queryInteger(c.req.param("id"), 0, { min: 1 }) - const { visible } = await myEvaluatedFlowcharts(c.get("user")!, problemId) - const latest = visible.at(-1) - return success(c, { - count: visible.length, - score: latest?.aiScore ?? 0, - grade: latest?.aiGrade ?? "", - } satisfies FlowchartCurrent) -}) - -flowchartRoutes.get("/problems/:id/flowchart/history", requireAuth, async (c) => { - const problemId = queryInteger(c.req.param("id"), 0, { min: 1 }) - const page = queryInteger(c.req.query("page"), 0, { min: 0 }) - const user = c.get("user")! - const { visible: rows } = await myEvaluatedFlowcharts(user, problemId) - const selected = page === 0 ? rows.at(-1) : rows[page - 1] - if (page > rows.length) return failure(c, 400, "page-out-of-range", "Page out of range") - // 列表只带了分数,选中的那一条再按 id 取整行。都是本人的提交,用户名就是自己的 - const [full] = selected - ? await db - .select() - .from(schema.flowchartSubmission) - .where(eq(schema.flowchartSubmission.id, selected.id)) - .limit(1) - : [] - return success(c, { - submission: full ? flowchartData(full, user.username) : null, - count: rows.length, - } satisfies FlowchartDetail) -}) - /** - * 历次分数:结果页签上那一排「第 N 次 xx 分」。原来 history 一次只给一条, - * 要看分数走势得一页一页翻。`hidden` 是被题单闸门藏起来的次数,界面上给一句说明。 + * 历次分数:结果页签上那一排「C → B → A」。原来的 history 一次只给一条, + * 要看走势得一页一页翻(它和 current 已经删了)。`hidden` 是被题单闸门藏起来的次数,界面上给一句说明。 */ flowchartRoutes.get("/problems/:id/flowchart/scores", requireAuth, async (c) => { const problemId = queryInteger(c.req.param("id"), 0, { min: 1 }) diff --git a/packages/contract/src/flowchart.ts b/packages/contract/src/flowchart.ts index a560351..d1cac84 100644 --- a/packages/contract/src/flowchart.ts +++ b/packages/contract/src/flowchart.ts @@ -66,16 +66,6 @@ export const createFlowchartResponseSchema = z.object({ submissionId: z.string(), status: z.literal("pending"), }) -export const flowchartCurrentSchema = z.object({ - count: z.number().int(), - score: z.number(), - grade: z.string(), -}) -export const flowchartDetailSchema = z.object({ - submission: flowchartSubmissionSchema.nullable(), - count: z.number().int(), -}) - /** * 流程图画到这两档算这道题做完:题单进度、课堂条、课堂看板、「你画的流程图」、结果页签的 ✓ * 都按它(设计文档 2026-09-28-problem-page-redesign 第 3 节决定 4、6)。前后端只有这一份 @@ -177,8 +167,6 @@ export type FlowchartStatistics = z.infer export type FlowchartSubmission = z.infer export type FlowchartListItem = z.infer export type FlowchartList = z.infer -export type FlowchartCurrent = z.infer -export type FlowchartDetail = z.infer export type FlowchartScores = z.infer export type CreateFlowchartResponse = z.infer export type CreateFlowchartRequest = z.infer