fix(题目列表): 新生和没登录的人点「随便来一道」,每次都是同一道题
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f21f15c43
commit
c3927d522c
1 file changed
+3
-1
@@ -282,8 +282,10 @@ problemRoutes.get("/problems/random", optionalAuth, async (c) => {
|
||||
: undefined,
|
||||
),
|
||||
)
|
||||
// 没做对过题(没登录、新生)就不排这一项。别拿 sql`1` 占位:ORDER BY 里的整数常量是
|
||||
// 「按第 1 列排」,会先按题号排、random() 形同虚设,每次都是同一道
|
||||
.orderBy(
|
||||
solved.length ? asc(inArray(schema.problem.id, solved)) : sql`1`,
|
||||
...(solved.length ? [asc(inArray(schema.problem.id, solved))] : []),
|
||||
asc(sql`${schema.problem.difficulty} = 'High'`),
|
||||
sql`random()`,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user