chore(流程图): 删掉前端两周前就不再调的 flowchart/current、history 两个接口

9-28 题目页重构后结果页签只用 scores + GET /flowcharts/:id,这两个留着是给上线那一刻
还开着旧页面的浏览器,现在可以删了,契约里对应的两份形状一起删。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-12 21:25:51 +08:00
1 parent e4905fcec1
commit 6b7d87d677
2 files changed
+4 -55

No files matched your search

+4 -43
View File
@@ -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 })
-12
View File
@@ -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<typeof flowchartStatisticsSchema>
export type FlowchartSubmission = z.infer<typeof flowchartSubmissionSchema>
export type FlowchartListItem = z.infer<typeof flowchartListItemSchema>
export type FlowchartList = z.infer<typeof flowchartListSchema>
export type FlowchartCurrent = z.infer<typeof flowchartCurrentSchema>
export type FlowchartDetail = z.infer<typeof flowchartDetailSchema>
export type FlowchartScores = z.infer<typeof flowchartScoresSchema>
export type CreateFlowchartResponse = z.infer<typeof createFlowchartResponseSchema>
export type CreateFlowchartRequest = z.infer<typeof createFlowchartRequestSchema>