fix chart
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2026-09-03 02:35:29 -06:00
parent 7129f1a12d
commit 69883bd016
13 changed files with 180 additions and 81 deletions

View File

@@ -102,6 +102,7 @@ async function buildDetail(user: AuthUser, start: string, end: string) {
const problemIds = firstAc.map((item) => item.problemId)
if (!problemIds.length) return aiDetailSchema.parse({
user: user.username, className: user.className, start, end, solved: [], flowcharts: [], grade: "", tags: {}, difficulty: {}, contestCount: 0,
rankScope: "global",
})
const classUsers = user.className ? await db.select({ id: schema.user.id }).from(schema.user).where(eq(schema.user.className, user.className)) : []
const scopeIds = classUsers.length > 1 ? classUsers.map((item) => item.id) : null
@@ -166,6 +167,7 @@ async function buildDetail(user: AuthUser, start: string, end: string) {
user: user.username, className: user.className, start, end, solved, flowcharts,
grade: averageGrade(solved.map((item) => item.grade)), tags: topTags, difficulty,
contestCount: new Set(solved.flatMap((item) => item.problem.contestId ?? [])).size,
rankScope: scopeIds ? "class" : "global",
})
}
@@ -258,7 +260,8 @@ async function buildDuration(user: AuthUser, endText: string, duration: string)
const from = bucket.start.getTime()
const to = bucket.end.getTime()
const inRange = rows.filter((row) => row.time >= from && row.time <= to)
const solved = [...new Set(inRange.filter((row) => accepted.includes(row.result)).map((row) => row.problemId))]
const acceptedRows = inRange.filter((row) => accepted.includes(row.result))
const solved = [...new Set(acceptedRows.map((row) => row.problemId))]
return durationDataSchema.parse({
unit: config.unit,
index: config.count - 1 - index,
@@ -266,6 +269,7 @@ async function buildDuration(user: AuthUser, endText: string, duration: string)
end: bucket.end.toISOString(),
grade: solved.length ? bucketGrade(solved, from, to) : "",
problemCount: solved.length,
acceptedCount: acceptedRows.length,
submissionCount: inRange.length,
})
})