core: set a minimum judge priority

This commit is contained in:
undefined committed 2023-03-26 23:01:36 +08:00
1 parent dde46c6e7f
commit 4db06398ae
2 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ import {
} from 'lodash'; } from 'lodash';
import { Filter, ObjectId } from 'mongodb'; import { Filter, ObjectId } from 'mongodb';
import { import {
ContestNotAttendedError, ContestNotFoundError, HackRejudgeFailedError, ContestNotFoundError, HackRejudgeFailedError,
PermissionError, ProblemConfigError, PermissionError, ProblemConfigError,
ProblemNotFoundError, RecordNotFoundError, UserNotFoundError, ProblemNotFoundError, RecordNotFoundError, UserNotFoundError,
} from '../error'; } from '../error';
+3 -2
View File
@@ -28,11 +28,12 @@ export default class RecordModel {
static async submissionPriority(uid: number, base: number = 0) { static async submissionPriority(uid: number, base: number = 0) {
const timeRecent = await RecordModel.coll const timeRecent = await RecordModel.coll
.find({ _id: { $gte: Time.getObjectID(moment().add(-30, 'minutes')) }, uid }).project({ time: 1, status: 1 }).toArray(); .find({ _id: { $gte: Time.getObjectID(moment().add(-30, 'minutes')) }, uid, rejudged: { $ne: true } })
.project({ time: 1, status: 1 }).toArray();
const pending = timeRecent.filter((i) => [ const pending = timeRecent.filter((i) => [
STATUS.STATUS_WAITING, STATUS.STATUS_FETCHED, STATUS.STATUS_COMPILING, STATUS.STATUS_JUDGING, STATUS.STATUS_WAITING, STATUS.STATUS_FETCHED, STATUS.STATUS_COMPILING, STATUS.STATUS_JUDGING,
].includes(i.status)).length; ].includes(i.status)).length;
return base - (pending * 1000 + 1) * (sum(timeRecent.map((i) => i.time || 0)) / 10000 + 1); return Math.max(base - 10000, base - (pending * 1000 + 1) * (sum(timeRecent.map((i) => i.time || 0)) / 10000 + 1));
} }
static async get(_id: ObjectId): Promise<RecordDoc | null>; static async get(_id: ObjectId): Promise<RecordDoc | null>;