mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: provide score & subtaskId
This commit is contained in:
1 parent
60aa0e1611
commit
a585c13a72
19 files changed
+118
-186
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.13.4",
|
||||
"version": "3.13.5",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -41,19 +41,19 @@ export async function postJudge(rdoc: RecordDoc) {
|
||||
await bus.serial('record/judge', rdoc, updated);
|
||||
}
|
||||
|
||||
export async function next(body: JudgeResultBody) {
|
||||
export async function next(body: Partial<JudgeResultBody>) {
|
||||
body.rid = new ObjectID(body.rid);
|
||||
let rdoc = await record.get(body.rid);
|
||||
if (!rdoc) return;
|
||||
const $set: Partial<RecordDoc> = {};
|
||||
const $push: any = {};
|
||||
if (body.case) {
|
||||
const c: TestCase = {
|
||||
const c: Required<TestCase> = {
|
||||
...body.case,
|
||||
id: body.case.id || 0,
|
||||
memory: body.case.memory,
|
||||
time: body.case.time,
|
||||
subtaskId: body.case.subtaskId || 0,
|
||||
score: body.case.score || 0,
|
||||
message: body.case.message || '',
|
||||
status: body.case.status,
|
||||
};
|
||||
rdoc.testCases.push(c);
|
||||
$push.testCases = c;
|
||||
@@ -75,7 +75,7 @@ export async function next(body: JudgeResultBody) {
|
||||
bus.broadcast('record/change', rdoc!, $set, $push);
|
||||
}
|
||||
|
||||
export async function end(body: JudgeResultBody) {
|
||||
export async function end(body: Partial<JudgeResultBody>) {
|
||||
if (body.rid) body.rid = new ObjectID(body.rid);
|
||||
let rdoc = await record.get(body.rid);
|
||||
if (!rdoc) return;
|
||||
|
||||
@@ -289,7 +289,6 @@ export class ProblemRandomHandler extends ProblemHandler {
|
||||
const category = flattenDeep(decodeURIComponent(qs).split(' ')
|
||||
.filter((i) => i.startsWith('category:'))
|
||||
.map((i) => i.split('category:')[1]?.split(',')));
|
||||
console.log(qs, category);
|
||||
const q = buildQuery(this.user);
|
||||
if (category.length) q.$and = category.map((tag) => ({ tag }));
|
||||
await bus.serial('problem/list', q, this);
|
||||
|
||||
@@ -183,7 +183,7 @@ class RecordDetailHandler extends Handler {
|
||||
time: 0,
|
||||
memory: 0,
|
||||
testCases: [{
|
||||
status: 9, score: 0, time: 0, memory: 0, message: 'score canceled',
|
||||
id: 0, subtaskId: 0, status: 9, score: 0, time: 0, memory: 0, message: 'score canceled',
|
||||
}],
|
||||
};
|
||||
const [latest] = await Promise.all([
|
||||
|
||||
@@ -2,7 +2,6 @@ import type fs from 'fs';
|
||||
import type { Dictionary, NumericDictionary } from 'lodash';
|
||||
import type { ItemBucketMetadata } from 'minio';
|
||||
import type { Cursor, ObjectID } from 'mongodb';
|
||||
import type { Readable, Writable } from 'stream';
|
||||
import type { ProblemDoc } from './model/problem';
|
||||
|
||||
type document = typeof import('./model/document');
|
||||
@@ -208,6 +207,7 @@ export interface SampleContentNode {
|
||||
sectionTitle: string,
|
||||
payload: [string, string],
|
||||
}
|
||||
// TODO drop contentNode support
|
||||
export type ContentNode = PlainContentNode | TextContentNode | SampleContentNode;
|
||||
export type Content = string | ContentNode[] | Record<string, ContentNode[]>;
|
||||
|
||||
@@ -272,6 +272,8 @@ export interface ProblemStatusDoc extends StatusDoc {
|
||||
|
||||
export interface TestCase {
|
||||
id?: number;
|
||||
subtaskId?: number;
|
||||
score?: number;
|
||||
time: number;
|
||||
memory: number;
|
||||
status: number;
|
||||
@@ -288,9 +290,9 @@ export interface RecordDoc {
|
||||
score: number;
|
||||
memory: number;
|
||||
time: number;
|
||||
judgeTexts: string[];
|
||||
judgeTexts: (string | JudgeMessage)[];
|
||||
compilerTexts: string[];
|
||||
testCases: TestCase[];
|
||||
testCases: Required<TestCase>[];
|
||||
rejudged: boolean;
|
||||
source?: string;
|
||||
/** judge uid */
|
||||
@@ -497,24 +499,25 @@ export interface Script {
|
||||
validate: any,
|
||||
}
|
||||
|
||||
export interface JudgeMessage {
|
||||
message: string;
|
||||
params?: string[];
|
||||
stack?: string;
|
||||
}
|
||||
|
||||
export interface JudgeResultBody {
|
||||
key: string;
|
||||
domainId: string;
|
||||
rid: ObjectID;
|
||||
judger?: number;
|
||||
progress?: number;
|
||||
addProgress?: number;
|
||||
case?: {
|
||||
id?: number;
|
||||
status: number;
|
||||
time: number;
|
||||
memory: number;
|
||||
message?: string;
|
||||
},
|
||||
case?: TestCase,
|
||||
status?: number;
|
||||
score?: number;
|
||||
time?: number;
|
||||
memory?: number;
|
||||
message?: string;
|
||||
message?: string | JudgeMessage;
|
||||
compilerText?: string,
|
||||
}
|
||||
|
||||
@@ -527,19 +530,6 @@ export interface Task {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface UploadStream extends Writable {
|
||||
id: ObjectID;
|
||||
}
|
||||
|
||||
export interface HydroFileSystem {
|
||||
openUploadStream: (filename: string) => UploadStream
|
||||
openDownloadStream: (_id: ObjectID) => Readable
|
||||
// TODO
|
||||
find: (...args: any[]) => any
|
||||
}
|
||||
|
||||
export type PathComponent = [string, string, Dictionary<any>?, boolean?];
|
||||
|
||||
export interface BaseService {
|
||||
started: boolean;
|
||||
error?: Error | string;
|
||||
@@ -637,7 +627,6 @@ export interface Model {
|
||||
export interface Service {
|
||||
bus: typeof import('./service/bus'),
|
||||
db: typeof import('./service/db'),
|
||||
fs: HydroFileSystem,
|
||||
monitor: typeof import('./service/monitor'),
|
||||
server: typeof import('./service/server'),
|
||||
storage: typeof import('./service/storage'),
|
||||
|
||||
@@ -95,7 +95,7 @@ app.on('error', (error) => {
|
||||
}
|
||||
});
|
||||
wsServer.on('error', (error) => {
|
||||
console.log(123, error);
|
||||
console.log('Websocket server error:', error);
|
||||
});
|
||||
|
||||
const ignoredLimit = `,${argv.options.ignoredLimit},`;
|
||||
|
||||
Reference in new issue
Block a user