core: stop existing task before rejudge

This commit is contained in:
undefined committed 2022-10-06 20:31:33 +08:00
1 parent 0facd0b433
commit b36adcdf13
3 files changed
+5 -4

No files matched your search

+1 -1
View File
@@ -102,7 +102,7 @@ export async function postJudge(rdoc: RecordDoc) {
status: STATUS.STATUS_ACCEPTED,
contest: { $ne: new ObjectID('0'.repeat(24)) },
}).project({ _id: 1, contest: 1 }).toArray();
const priority = await record.submissionPriority(rdoc.uid, -rdocs.length * 5 - 50);
const priority = await record.submissionPriority(rdoc.uid, -5000 - rdocs.length * 5 - 50);
await Promise.all(rdocs.map(
(r) => record.judge(rdoc.domainId, r._id, priority, r.contest ? { detail: false } : {}, { hackRejudge: input }),
));
+1 -1
View File
@@ -445,7 +445,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
contest: { $ne: new ObjectID('0'.repeat(24)) },
'files.hack': { $exists: false },
}).project({ _id: 1, contest: 1 }).toArray();
const priority = await record.submissionPriority(this.user._id, -rdocs.length * 5 - 50);
const priority = await record.submissionPriority(this.user._id, -10000 - rdocs.length * 5 - 50);
await Promise.all(rdocs.map(
(doc) => record.reset(domainId, doc._id, true)
.then(() => record.judge(domainId, doc._id, priority, doc.contest ? { detail: false } : {})),
+3 -2
View File
@@ -33,7 +33,7 @@ export default class RecordModel {
const pending = timeRecent.filter((i) => [
STATUS.STATUS_WAITING, STATUS.STATUS_FETCHED, STATUS.STATUS_COMPILING, STATUS.STATUS_JUDGING,
].includes(i.status)).length;
return base - ((pending * 1000 + 1) * (sum(timeRecent.map((i) => i.time || 0)) / 10000) + 1);
return base - (pending * 1000 + 1) * (sum(timeRecent.map((i) => i.time || 0)) / 10000 + 1);
}
static async get(_id: ObjectID): Promise<RecordDoc | null>;
@@ -197,7 +197,7 @@ export default class RecordModel {
return res.modifiedCount;
}
static reset(domainId: string, rid: MaybeArray<ObjectID>, isRejudge: boolean) {
static async reset(domainId: string, rid: MaybeArray<ObjectID>, isRejudge: boolean) {
const upd: any = {
score: 0,
status: STATUS.STATUS_WAITING,
@@ -210,6 +210,7 @@ export default class RecordModel {
judger: null,
};
if (isRejudge) upd.rejudged = true;
await task.deleteMany(rid instanceof Array ? { rid: { $in: rid } } : { rid });
return RecordModel.update(domainId, rid, upd);
}