mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge, problem_settings, problem_upload
This commit is contained in:
1 parent
5b4f5b6520
commit
b3024bebb0
45 files changed
+598
-250
No files matched your search
+47
-2
@@ -14,7 +14,7 @@ GET('/judge/fetch', requirePerm(PERM_JUDGE), async ctx => {
|
||||
let rid = await queue.get('judge', false);
|
||||
if (rid) {
|
||||
let rdoc = await record.get(rid);
|
||||
let data = {
|
||||
let task = {
|
||||
event: 'judge',
|
||||
rid, type: 0,
|
||||
pid: rdoc.pid,
|
||||
@@ -22,12 +22,57 @@ GET('/judge/fetch', requirePerm(PERM_JUDGE), async ctx => {
|
||||
lang: rdoc.lang,
|
||||
code: rdoc.code
|
||||
};
|
||||
ctx.body = data;
|
||||
ctx.body = { task };
|
||||
}
|
||||
else ctx.body = {};
|
||||
});
|
||||
POST('/judge/next', requirePerm(PERM_JUDGE), async ctx => {
|
||||
console.log(ctx.request.body);
|
||||
let body = ctx.request.body;
|
||||
let rdoc = await record.get(body.rid);
|
||||
let $set = {};
|
||||
if (body.case) {
|
||||
rdoc.testCases.push(body.case);
|
||||
$set.testCases = rdoc.testCases;
|
||||
}
|
||||
if (body.judge_text) {
|
||||
rdoc.judgeTexts.push(body.judge_text);
|
||||
$set.judgeTexts = rdoc.judgeTexts;
|
||||
}
|
||||
if (body.compiler_text) {
|
||||
rdoc.compilerTexts.push(body.compilerTexts);
|
||||
$set.compilerTexts = rdoc.compilerTexts;
|
||||
}
|
||||
if (body.status) $set.status = body.status;
|
||||
if (body.score) $set.score = body.score;
|
||||
if (body.time_ms) $set.time = body.time_ms;
|
||||
if (body.memory_kb) $set.memory = body.memory_kb;
|
||||
await record.update(body.rid, $set);
|
||||
ctx.body = {};
|
||||
});
|
||||
POST('/judge/end', requirePerm(PERM_JUDGE), async ctx => {
|
||||
console.log(ctx.request.body);
|
||||
let body = ctx.request.body;
|
||||
let rdoc = await record.get(body.rid);
|
||||
let $set = {};
|
||||
if (body.case) {
|
||||
rdoc.testCases.push(body.case);
|
||||
$set.testCases = rdoc.testCases;
|
||||
}
|
||||
if (body.judge_text) {
|
||||
rdoc.judgeTexts.push(body.judge_text);
|
||||
$set.judgeTexts = rdoc.judgeTexts;
|
||||
}
|
||||
if (body.compiler_text) {
|
||||
rdoc.compilerTexts.push(body.compilerTexts);
|
||||
$set.compilerTexts = rdoc.compilerTexts;
|
||||
}
|
||||
if (body.status) $set.status = body.status;
|
||||
if (body.score) $set.score = body.score;
|
||||
if (body.time_ms) $set.time = body.time_ms;
|
||||
if (body.memory_kb) $set.memory = body.memory_kb;
|
||||
$set.judgeAt = new Date();
|
||||
$set.judger = ctx.state.user._id;
|
||||
await record.update(body.rid, $set);
|
||||
ctx.body = {};
|
||||
});
|
||||
Reference in new issue
Block a user