From 68e641f28f49223e48550f6146d1e701910b6816 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 24 Mar 2025 19:43:46 +0800 Subject: [PATCH] core: skip if no record selected to rejudge --- packages/hydrooj/src/handler/problem.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 23778f9f5..f27800b03 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -395,19 +395,21 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler { @param('pid', Types.UnsignedInt) async postRejudge(domainId: string, pid: number) { this.checkPerm(PERM.PERM_REJUDGE_PROBLEM); + if (!this.pdoc.config || typeof this.pdoc.config === 'string') throw new ProblemConfigError(); const rdocs = await record.getMulti(domainId, { pid, contest: { $nin: [record.RECORD_GENERATE, record.RECORD_PRETEST] }, status: { $ne: STATUS.STATUS_CANCELED }, 'files.hack': { $exists: false }, }).project({ _id: 1, contest: 1 }).toArray(); - if (!this.pdoc.config || typeof this.pdoc.config === 'string') throw new ProblemConfigError(); - const priority = await record.submissionPriority(this.user._id, -10000 - rdocs.length * 5 - 50); - await record.reset(domainId, rdocs.map((rdoc) => rdoc._id), true); - await Promise.all([ - record.judge(domainId, rdocs.filter((i) => i.contest).map((i) => i._id), priority, { detail: false }, { rejudge: true }), - record.judge(domainId, rdocs.filter((i) => !i.contest).map((i) => i._id), priority, {}, { rejudge: true }), - ]); + if (rdocs.length) { + const priority = await record.submissionPriority(this.user._id, -10000 - rdocs.length * 5 - 50); + await record.reset(domainId, rdocs.map((rdoc) => rdoc._id), true); + await Promise.all([ + record.judge(domainId, rdocs.filter((i) => i.contest).map((i) => i._id), priority, { detail: false }, { rejudge: true }), + record.judge(domainId, rdocs.filter((i) => !i.contest).map((i) => i._id), priority, {}, { rejudge: true }), + ]); + } this.back(); }