feat(智能分析): 解题表格改服务端分页,/ai/detail 不再下发整份 solved
Some checks failed
Deploy / deploy (push) Has been cancelled
Some checks failed
Deploy / deploy (push) Has been cancelled
原来 /ai/detail 把区间内做出来的每道题连排名带等级整份下发,一个活跃学生一年几百道, 一次请求就是几百 KB,而表格一屏只看得到二十行。 拆成两支: - GET /ai/detail 只留聚合(solvedCount、difficulty、tags、attempts、activity、errors…) - GET /ai/solved?offset&limit 按首次通过时间升序分页给逐题明细 排名只跟当前这批题有关,所以分页那支只算一页的 problemIds,不必把整年算一遍。抽出 firstAcQuery / buildSolved / listSolved 三个函数,detail 和分页两边共用。 前端相应改动: - 难度分布改读后端的 difficulty 聚合(本来就在下发,之前是从逐题列表里现数的) - 几次做对改读新的 attempts 数组(每道题的尝试次数);tooltip 里的题名去掉了 —— 明细是分页拿的,不该为了一个 tooltip 把全量拉回来 - Overview 用 solvedCount - SolvedTable 的代码提交那张走 remote 分页,流程图那张仍是本地分页(一个 OJ 的 流程图题就那么几道,全量下发没问题);换时间范围回到第一页 - 表格原来是 max-height 1500 的滚动区,现在由分页兜住,滚动条和分页器不再并存 /ai/analysis 的 prompt 仍然带逐题明细(少了它模型只剩聚合数字),但顺手卡了 200 条 —— 以前是整份 solved 无上限塞进去,题做得多的学生一次调用能顶好几倍 token。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LZuPwqDmLEiK9zgQ9z9sVn
This commit is contained in:
@@ -63,7 +63,13 @@ export const aiDetailSchema = z.object({
|
||||
className: z.string().nullable(),
|
||||
start: z.string(),
|
||||
end: z.string(),
|
||||
solved: z.array(solvedProblemSchema),
|
||||
/**
|
||||
* 区间内做出来的题数。逐题明细走 `GET /ai/solved` 分页拿 ——
|
||||
* 一个活跃学生一年能做几百道,整份塞进这个响应没有必要。
|
||||
*/
|
||||
solvedCount: z.number().int(),
|
||||
/** 每道做出来的题「到首次通过为止提交了几次」,分档放在前端 */
|
||||
attempts: z.array(z.number().int()),
|
||||
flowcharts: z.array(flowchartSummarySchema),
|
||||
grade: gradeSchema,
|
||||
tags: z.record(z.string(), z.number().int()),
|
||||
@@ -91,6 +97,12 @@ export const aiDetailSchema = z.object({
|
||||
* 以前是 `details: z.unknown()` / `duration: z.unknown()` —— 前端算好的整包 POST 回去,
|
||||
* 原样进 prompt 又原样写进 ai_analysis 表,等于让任何登录用户决定喂给模型什么。
|
||||
*/
|
||||
/** GET /ai/solved 的分页响应 */
|
||||
export const solvedListSchema = z.object({
|
||||
results: z.array(solvedProblemSchema),
|
||||
total: z.number().int(),
|
||||
})
|
||||
|
||||
export const aiAnalysisRequestSchema = z.object({
|
||||
start: z.string().min(1),
|
||||
end: z.string().min(1),
|
||||
@@ -150,6 +162,7 @@ export type SolvedProblem = z.infer<typeof solvedProblemSchema>
|
||||
export type FlowchartSummary = z.infer<typeof flowchartSummarySchema>
|
||||
export type ActivityBucket = z.infer<typeof activityBucketSchema>
|
||||
export type AiDetail = z.infer<typeof aiDetailSchema>
|
||||
export type SolvedList = z.infer<typeof solvedListSchema>
|
||||
export type HeatmapItem = z.infer<typeof heatmapItemSchema>
|
||||
export type AiAnalysisRecord = z.infer<typeof aiAnalysisRecordSchema>
|
||||
export type LoginSummary = z.infer<typeof loginSummarySchema>
|
||||
|
||||
Reference in New Issue
Block a user