fix hack rejudge & rejudge all

This commit is contained in:
panda authored and undefined committed 2022-09-06 13:02:46 +08:00
1 parent bdc0b21e88
commit fe0cd78db7
5 files changed
+20 -10

No files matched your search

+1 -1
View File
@@ -103,7 +103,7 @@ export async function postJudge(rdoc: RecordDoc) {
}).project({ _id: 1, contest: 1 }).toArray();
const priority = await record.submissionPriority(this.user._id, -rdocs.length * 5 - 50);
await Promise.all(rdocs.map(
(r) => record.judge(r.domainId, r._id, priority, r.contest ? { detail: false } : {}, { hackRejudge: input }),
(r) => record.judge(rdoc.domainId, r._id, priority, r.contest ? { detail: false } : {}, { hackRejudge: input }),
));
} catch (e) {
next({
+5 -1
View File
@@ -431,7 +431,11 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
async postRejudge(domainId: string, pid: number) {
this.checkPerm(PERM.PERM_REJUDGE_PROBLEM);
// TODO maybe async?
const rdocs = await record.getMulti(domainId, { pid, contest: { $ne: new ObjectID('0'.repeat(24)) } })
const rdocs = await record.getMulti(domainId, {
pid,
contest: { $ne: new ObjectID('0'.repeat(24)) },
status: { $ne: [STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL] },
})
.project({ _id: 1, contest: 1 }).toArray();
const priority = await record.submissionPriority(this.user._id, -rdocs.length * 5 - 50);
await Promise.all(rdocs.map(
+4 -1
View File
@@ -1,7 +1,7 @@
import { debounce, omit } from 'lodash';
import { FilterQuery, ObjectID } from 'mongodb';
import {
ContestNotAttendedError, ContestNotFoundError, PermissionError,
ContestNotAttendedError, ContestNotFoundError, ForbiddenError, PermissionError,
ProblemNotFoundError, RecordNotFoundError, UserNotFoundError,
} from '../error';
import { RecordDoc, Tdoc } from '../interface';
@@ -173,6 +173,9 @@ class RecordDetailHandler extends Handler {
@param('rid', Types.ObjectID)
async postRejudge(domainId: string, rid: ObjectID) {
this.checkPerm(PERM.PERM_REJUDGE);
if ([STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL].find((i) => i === this.rdoc.status)) {
throw new ForbiddenError('Cannot rejudge hack record.');
}
const priority = await record.submissionPriority(this.user._id, -20);
const isContest = this.rdoc.contest && this.rdoc.contest.toString() !== '000000000000000000000000';
await record.reset(domainId, rid, true);