core: handle isContest

This commit is contained in:
undefined committed 2021-10-06 16:55:08 +08:00
1 parent 649cc21f12
commit d57442bf5f
3 files changed
+6 -10

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.39.10", "version": "2.39.11",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+1 -1
View File
@@ -381,7 +381,7 @@ export class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
throw new BadRequestError('Language not allowed.'); throw new BadRequestError('Language not allowed.');
} }
await this.limitRate('add_record', 60, system.get('limit.submission')); await this.limitRate('add_record', 60, system.get('limit.submission'));
const rid = await record.add(domainId, pid, this.user._id, lang, code, true, pretest ? input : tid); const rid = await record.add(domainId, pid, this.user._id, lang, code, true, pretest ? input : tid, !pretest);
const rdoc = await record.get(domainId, rid); const rdoc = await record.get(domainId, rid);
if (!rdoc) throw new RecordNotFoundError(domainId, rid); if (!rdoc) throw new RecordNotFoundError(domainId, rid);
if (!pretest) { if (!pretest) {
+4 -8
View File
@@ -97,7 +97,7 @@ class RecordModel {
static async add( static async add(
domainId: string, pid: ExternalProblemId | number, uid: number, domainId: string, pid: ExternalProblemId | number, uid: number,
lang: string, code: string, addTask: boolean, contestOrConfig?: ObjectID | string, lang: string, code: string, addTask: boolean, tidOrInput?: ObjectID | string, isContest?: boolean
) { ) {
let pdomain = domainId; let pdomain = domainId;
if (typeof pid === 'string') { if (typeof pid === 'string') {
@@ -123,15 +123,11 @@ class RecordModel {
judgeAt: null, judgeAt: null,
rejudged: false, rejudged: false,
}; };
let isContest = false; if (typeof tidOrInput === 'string') {
if (typeof contestOrConfig === 'string') {
// is Run // is Run
data.input = contestOrConfig; data.input = tidOrInput;
data.contest = new ObjectID('000000000000000000000000'); data.contest = new ObjectID('000000000000000000000000');
} else { } else data.contest = tidOrInput;
data.contest = contestOrConfig;
isContest = true;
}
const res = await RecordModel.coll.insertOne(data); const res = await RecordModel.coll.insertOne(data);
if (addTask) { if (addTask) {
const priority = await RecordModel.submissionPriority(uid, isContest ? 50 : 0); const priority = await RecordModel.submissionPriority(uid, isContest ? 50 : 0);