mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui&judge: allow run multiple pretests in single request (#1098)
This commit is contained in:
1 parent
c45975ae33
commit
114be2848b
8 files changed
+53
-39
No files matched your search
@@ -103,7 +103,7 @@ class SystemScriptHandler extends SystemHandler {
|
||||
if (typeof global.Hydro.script[id].validate === 'function') {
|
||||
args = global.Hydro.script[id].validate(args);
|
||||
}
|
||||
const rid = await record.add(domainId, -1, this.user._id, '-', id, false, { input: raw, type: 'pretest' });
|
||||
const rid = await record.add(domainId, -1, this.user._id, '-', id, false, { input: [raw], type: 'pretest' });
|
||||
const c = new JudgeResultCallbackContext(this.ctx, { type: 'judge', domainId, rid });
|
||||
c.next({ message: `Running script: ${id} `, status: STATUS.STATUS_JUDGING });
|
||||
const start = Date.now();
|
||||
|
||||
@@ -483,9 +483,9 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
@param('lang', Types.Name)
|
||||
@param('code', Types.String, true)
|
||||
@param('pretest', Types.Boolean)
|
||||
@param('input', Types.String, true)
|
||||
@param('input', Types.ArrayOf(Types.String), true)
|
||||
@param('tid', Types.ObjectId, true)
|
||||
async post(domainId: string, lang: string, code: string, pretest = false, input = '', tid?: ObjectId) {
|
||||
async post(domainId: string, lang: string, code: string, pretest = false, input: string[] = [], tid?: ObjectId) {
|
||||
const config = this.pdoc.config;
|
||||
if (typeof config === 'string' || config === null) throw new ProblemConfigError();
|
||||
if (['submit_answer', 'objective'].includes(config.type)) {
|
||||
@@ -498,6 +498,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
if (!['default', 'remote_judge'].includes(this.response.body.pdoc.config?.type)) {
|
||||
throw new ProblemNotAllowPretestError('type');
|
||||
}
|
||||
if (!input.length) throw new ValidationError('input');
|
||||
}
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission_user'), '{{user}}');
|
||||
await this.limitRate('add_record', 60, pretest ? system.get('limit.pretest') : system.get('limit.submission'));
|
||||
|
||||
@@ -131,7 +131,7 @@ export default class RecordModel {
|
||||
lang: string, code: string, addTask: boolean,
|
||||
args: {
|
||||
contest?: ObjectId;
|
||||
input?: string;
|
||||
input?: string[];
|
||||
files?: Record<string, string>;
|
||||
hackTarget?: ObjectId;
|
||||
type: 'judge' | 'rejudge' | 'pretest' | 'hack' | 'generate';
|
||||
@@ -165,7 +165,7 @@ export default class RecordModel {
|
||||
args.type = 'judge';
|
||||
data.rejudged = true;
|
||||
} else if (args.type === 'pretest') {
|
||||
data.input = args.input || '';
|
||||
data.input = args.input || [];
|
||||
isContest = false;
|
||||
data.contest = RecordModel.RECORD_PRETEST;
|
||||
} else if (args.type === 'generate') {
|
||||
|
||||
Reference in new issue
Block a user