refactor: 一批名不副实的命名改掉(只动一端,不碰契约)

后端:
- getUserByToken → authenticateToken:它会删会话、续 TTL、记在线,不是纯读
- todayStart → dayStart(instant):本来就接受任意时刻,不只是「今天」
- objectValue → asRecord,删掉 4 份一模一样的私有拷贝和 `as toObject` 别名
- 报错文案 "does not exists" / "Already be a public problem" 改通顺

前端:
- utils/types 里 Contest / User / Problem 三个别名删掉:Contest 原来指后台
  比赛、契约里同名的却是学生侧。现在 Contest = 学生侧、AdminContest = 后台,
  后台用户表单叫 AdminUserForm,题目详情直接用 ProblemDetail
- SubmissionInfo → ContestSubmissionInfo,免得和 submission.info 撞名
- utoa / atou → compressToBase64 / decompressFromBase64(实际是 zlib + base64),
  encode / decode → base64EncodeUtf8 / base64DecodeUtf8
- filterResult → toProblemRow、toProblemListItem → toAdminProblemRow,
  行字段 submission / rate → submissionCount / acRate
- 组件:Modal → AddFromLibraryModal、Form → EditorToolbar、
  ContestEditor → BasicEditor(题单也在用它)、rank 的 Index → RankMedal、
  Name → UserNameCell、Password → PasswordCell、ContestType → ContestAccessTag

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-09-27 16:08:21 +08:00
1 parent 572a818d49
commit 5ae830a7f9
62 files changed
+284 -320

No files matched your search

+5 -5
View File
@@ -1,7 +1,7 @@
import { and, eq, notInArray, sql } from "drizzle-orm"
import { db, schema } from "../db"
import { objectValue } from "../routes/helpers"
import { asRecord } from "../routes/helpers"
type BadgeRow = typeof schema.problemsetBadge.$inferSelect
type ProgressRow = typeof schema.problemsetProgress.$inferSelect
@@ -40,7 +40,7 @@ export function computeProgress(
if (score === undefined) continue
totalScore += score
// 分值以题单当前的设置为准,detail 里存的是做出那一刻的快照
kept[key] = { ...objectValue(value), score }
kept[key] = { ...asRecord(value), score }
}
// 分母只算必做题。「(选做)」这个标签一直只是卡片上的一行字,进度分母和 all_problems
// 奖章照样要求做完 —— 快照里 22 个人做完了全部必做题,界面却显示未完成、全通奖章也拿不到
@@ -137,7 +137,7 @@ export function eligibleForBadge(badge: BadgeRow, progress: BadgeCheck) {
}
if (badge.conditionType === "problem_count") {
return (
Object.keys(objectValue(progress.progressDetail)).length >=
Object.keys(asRecord(progress.progressDetail)).length >=
badge.conditionValue
)
}
@@ -232,7 +232,7 @@ export async function resyncProgress(problemsetId: number) {
const updated = progresses.map((progress) => ({
...progress,
...computeProgress(
objectValue(progress.progressDetail),
asRecord(progress.progressDetail),
links,
progress.completeTime,
now,
@@ -309,7 +309,7 @@ export async function recordSolvedProblem(
.values({ problemsetId, userId, submissionId, problemId })
}
const detail = objectValue(progress.progressDetail)
const detail = asRecord(progress.progressDetail)
if (String(problemId) in detail) return []
const links = await tx
.select({