mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
vjudge: codeforces&luogu: use cached callback
This commit is contained in:
2 files changed
+26
-25
No files matched your search
@@ -315,27 +315,29 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr
|
|||||||
submissionId: id,
|
submissionId: id,
|
||||||
});
|
});
|
||||||
if (body.compilationError === 'true') {
|
if (body.compilationError === 'true') {
|
||||||
await next({ compilerText: body['checkerStdoutAndStderr#1'] });
|
|
||||||
return await end({
|
return await end({
|
||||||
status: STATUS.STATUS_COMPILE_ERROR, score: 0, time: 0, memory: 0,
|
compilerText: body['checkerStdoutAndStderr#1'],
|
||||||
|
status: STATUS.STATUS_COMPILE_ERROR,
|
||||||
|
score: 0,
|
||||||
|
time: 0,
|
||||||
|
memory: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const time = Math.sum(Object.keys(body).filter((k) => k.startsWith('timeConsumed#')).map((k) => +body[k]));
|
const time = Math.sum(Object.keys(body).filter((k) => k.startsWith('timeConsumed#')).map((k) => +body[k]));
|
||||||
const memory = Math.max(...Object.keys(body).filter((k) => k.startsWith('memoryConsumed#')).map((k) => +body[k])) / 1024;
|
const memory = Math.max(...Object.keys(body).filter((k) => k.startsWith('memoryConsumed#')).map((k) => +body[k])) / 1024;
|
||||||
|
const cases = [];
|
||||||
for (; i <= +body.testCount; i++) {
|
for (; i <= +body.testCount; i++) {
|
||||||
const status = VERDICT[body[`verdict#${i}`]] || STATUS.STATUS_WRONG_ANSWER;
|
const status = VERDICT[body[`verdict#${i}`]] || STATUS.STATUS_WRONG_ANSWER;
|
||||||
await next({
|
cases.push({
|
||||||
status: STATUS.STATUS_JUDGING,
|
id: +i,
|
||||||
case: {
|
subtaskId: 1,
|
||||||
id: +i,
|
status,
|
||||||
subtaskId: 1,
|
time: +body[`timeConsumed#${i}`],
|
||||||
status,
|
memory: +body[`memoryConsumed#${i}`] / 1024,
|
||||||
time: +body[`timeConsumed#${i}`],
|
message: body[`checkerStdoutAndStderr#${i}`] || body[`verdict#${i}`],
|
||||||
memory: +body[`memoryConsumed#${i}`] / 1024,
|
|
||||||
message: body[`checkerStdoutAndStderr#${i}`] || body[`verdict#${i}`],
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (cases.length) await next({ status: STATUS.STATUS_JUDGING, cases });
|
||||||
if (body.waiting === 'true') continue;
|
if (body.waiting === 'true') continue;
|
||||||
const status = VERDICT[Object.keys(VERDICT).find((k) => normalize(body.verdict).includes(k))];
|
const status = VERDICT[Object.keys(VERDICT).find((k) => normalize(body.verdict).includes(k))];
|
||||||
return await end({
|
return await end({
|
||||||
|
|||||||
@@ -145,9 +145,10 @@ export default class LuoguProvider extends BasicFetcher implements IBasicProvide
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
logger.info('Fetched with length', JSON.stringify(body).length);
|
logger.info('Fetched with length', JSON.stringify(body).length);
|
||||||
const total = _.flattenDeep(body.currentData.testCaseGroup).length;
|
|
||||||
// TODO sorted
|
|
||||||
if (!data.detail.judgeResult?.subtasks) continue;
|
if (!data.detail.judgeResult?.subtasks) continue;
|
||||||
|
const total = _.flattenDeep(body.currentData.testCaseGroup).length;
|
||||||
|
const cases = [];
|
||||||
|
let progress = (finished / total) * 100;
|
||||||
for (const key in data.detail.judgeResult.subtasks) {
|
for (const key in data.detail.judgeResult.subtasks) {
|
||||||
const subtask = data.detail.judgeResult.subtasks[key];
|
const subtask = data.detail.judgeResult.subtasks[key];
|
||||||
for (const cid in subtask.testCases || {}) {
|
for (const cid in subtask.testCases || {}) {
|
||||||
@@ -155,20 +156,18 @@ export default class LuoguProvider extends BasicFetcher implements IBasicProvide
|
|||||||
finished++;
|
finished++;
|
||||||
done[`${subtask.id}.${cid}`] = true;
|
done[`${subtask.id}.${cid}`] = true;
|
||||||
const testcase = subtask.testCases[cid];
|
const testcase = subtask.testCases[cid];
|
||||||
await next({
|
cases.push({
|
||||||
status: STATUS.STATUS_JUDGING,
|
id: +cid || 0,
|
||||||
case: {
|
subtaskId: +subtask.id || 0,
|
||||||
id: +cid || 0,
|
status: STATUS_MAP[testcase.status],
|
||||||
subtaskId: +subtask.id || 0,
|
time: testcase.time,
|
||||||
status: STATUS_MAP[testcase.status],
|
memory: testcase.memory,
|
||||||
time: testcase.time,
|
message: testcase.description,
|
||||||
memory: testcase.memory,
|
|
||||||
message: testcase.description,
|
|
||||||
},
|
|
||||||
progress: (finished / total) * 100,
|
|
||||||
});
|
});
|
||||||
|
progress = (finished / total) * 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (cases.length) await next({ status: STATUS.STATUS_JUDGING, cases, progress });
|
||||||
if (data.status < 2) continue;
|
if (data.status < 2) continue;
|
||||||
logger.info('RecordID:', id, 'done');
|
logger.info('RecordID:', id, 'done');
|
||||||
// TODO calc total status
|
// TODO calc total status
|
||||||
|
|||||||
Reference in new issue
Block a user