mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
move delarations to @hydrooj/common
This commit is contained in:
1 parent
100ccf718f
commit
4a33816a37
49 files changed
+496
-465
No files matched your search
@@ -5,13 +5,12 @@ import { omit } from 'lodash';
|
||||
import { ObjectId } from 'mongodb';
|
||||
import PQueue from 'p-queue';
|
||||
import sanitize from 'sanitize-filename';
|
||||
import { JudgeResultBody, ProblemConfigFile, TestCase } from '@hydrooj/common';
|
||||
import { Context } from '../context';
|
||||
import {
|
||||
FileLimitExceededError, ForbiddenError, ProblemIsReferencedError, ValidationError,
|
||||
} from '../error';
|
||||
import {
|
||||
JudgeResultBody, ProblemConfigFile, RecordDoc, Task, TestCase,
|
||||
} from '../interface';
|
||||
import { RecordDoc, Task } from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
import * as builtin from '../model/builtin';
|
||||
import { PERM, STATUS } from '../model/builtin';
|
||||
@@ -73,11 +72,10 @@ function processPayload(body: Partial<JudgeResultBody>) {
|
||||
}
|
||||
|
||||
export async function next(body: Partial<JudgeResultBody>) {
|
||||
body.rid = new ObjectId(body.rid); // TODO remove this
|
||||
const {
|
||||
$set, $push, $unset, $inc,
|
||||
} = processPayload(body);
|
||||
const rdoc = await record.update(body.domainId, body.rid, $set, $push, $unset, $inc);
|
||||
const rdoc = await record.update(body.domainId, new ObjectId(body.rid), $set, $push, $unset, $inc);
|
||||
if (rdoc) bus.broadcast('record/change', rdoc, $set, $push, body);
|
||||
return rdoc;
|
||||
}
|
||||
@@ -139,12 +137,11 @@ bus.on('record/judge', async (rdoc, updated, pdoc) => {
|
||||
});
|
||||
|
||||
export async function end(body: Partial<JudgeResultBody>) {
|
||||
body.rid = new ObjectId(body.rid); // TODO remove this
|
||||
const { $set, $push } = processPayload(body);
|
||||
const $unset: any = { progress: '' };
|
||||
$set.judgeAt = new Date();
|
||||
$set.judger = body.judger ?? 1;
|
||||
const rdoc = await record.update(body.domainId, body.rid, $set, $push, $unset);
|
||||
const rdoc = await record.update(body.domainId, new ObjectId(body.rid), $set, $push, $unset);
|
||||
if (rdoc) bus.broadcast('record/change', rdoc, null, null, body); // trigger a full update
|
||||
await postJudge(rdoc);
|
||||
return rdoc;
|
||||
|
||||
@@ -115,7 +115,7 @@ class SystemScriptHandler extends SystemHandler {
|
||||
const time = new Date().getTime() - start;
|
||||
judge.end({
|
||||
domainId,
|
||||
rid,
|
||||
rid: rid.toHexString(),
|
||||
status: STATUS.STATUS_ACCEPTED,
|
||||
message: inspect(ret, false, 10, true),
|
||||
judger: 1,
|
||||
@@ -128,7 +128,7 @@ class SystemScriptHandler extends SystemHandler {
|
||||
logger.error(err);
|
||||
judge.end({
|
||||
domainId,
|
||||
rid,
|
||||
rid: rid.toHexString(),
|
||||
status: STATUS.STATUS_SYSTEM_ERROR,
|
||||
message: `${err.message} \n${(err as any).params || []} \n${err.stack} `,
|
||||
judger: 1,
|
||||
|
||||
Reference in new issue
Block a user