From c3927d522cbd72581b1405abb20d6b5dcb169dbc Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Fri, 9 Oct 2026 16:49:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A2=98=E7=9B=AE=E5=88=97=E8=A1=A8):=20?= =?UTF-8?q?=E6=96=B0=E7=94=9F=E5=92=8C=E6=B2=A1=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E4=BA=BA=E7=82=B9=E3=80=8C=E9=9A=8F=E4=BE=BF=E6=9D=A5=E4=B8=80?= =?UTF-8?q?=E9=81=93=E3=80=8D=EF=BC=8C=E6=AF=8F=E6=AC=A1=E9=83=BD=E6=98=AF?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E9=81=93=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/api/src/routes/problem.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/src/routes/problem.ts b/apps/api/src/routes/problem.ts index dc8e505..c362900 100644 --- a/apps/api/src/routes/problem.ts +++ b/apps/api/src/routes/problem.ts @@ -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()`, )