mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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,
|
||||
});
|
||||
if (body.compilationError === 'true') {
|
||||
await next({ compilerText: body['checkerStdoutAndStderr#1'] });
|
||||
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 memory = Math.max(...Object.keys(body).filter((k) => k.startsWith('memoryConsumed#')).map((k) => +body[k])) / 1024;
|
||||
const cases = [];
|
||||
for (; i <= +body.testCount; i++) {
|
||||
const status = VERDICT[body[`verdict#${i}`]] || STATUS.STATUS_WRONG_ANSWER;
|
||||
await next({
|
||||
status: STATUS.STATUS_JUDGING,
|
||||
case: {
|
||||
id: +i,
|
||||
subtaskId: 1,
|
||||
status,
|
||||
time: +body[`timeConsumed#${i}`],
|
||||
memory: +body[`memoryConsumed#${i}`] / 1024,
|
||||
message: body[`checkerStdoutAndStderr#${i}`] || body[`verdict#${i}`],
|
||||
},
|
||||
cases.push({
|
||||
id: +i,
|
||||
subtaskId: 1,
|
||||
status,
|
||||
time: +body[`timeConsumed#${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;
|
||||
const status = VERDICT[Object.keys(VERDICT).find((k) => normalize(body.verdict).includes(k))];
|
||||
return await end({
|
||||
|
||||
@@ -145,9 +145,10 @@ export default class LuoguProvider extends BasicFetcher implements IBasicProvide
|
||||
});
|
||||
}
|
||||
logger.info('Fetched with length', JSON.stringify(body).length);
|
||||
const total = _.flattenDeep(body.currentData.testCaseGroup).length;
|
||||
// TODO sorted
|
||||
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) {
|
||||
const subtask = data.detail.judgeResult.subtasks[key];
|
||||
for (const cid in subtask.testCases || {}) {
|
||||
@@ -155,20 +156,18 @@ export default class LuoguProvider extends BasicFetcher implements IBasicProvide
|
||||
finished++;
|
||||
done[`${subtask.id}.${cid}`] = true;
|
||||
const testcase = subtask.testCases[cid];
|
||||
await next({
|
||||
status: STATUS.STATUS_JUDGING,
|
||||
case: {
|
||||
id: +cid || 0,
|
||||
subtaskId: +subtask.id || 0,
|
||||
status: STATUS_MAP[testcase.status],
|
||||
time: testcase.time,
|
||||
memory: testcase.memory,
|
||||
message: testcase.description,
|
||||
},
|
||||
progress: (finished / total) * 100,
|
||||
cases.push({
|
||||
id: +cid || 0,
|
||||
subtaskId: +subtask.id || 0,
|
||||
status: STATUS_MAP[testcase.status],
|
||||
time: testcase.time,
|
||||
memory: testcase.memory,
|
||||
message: testcase.description,
|
||||
});
|
||||
progress = (finished / total) * 100;
|
||||
}
|
||||
}
|
||||
if (cases.length) await next({ status: STATUS.STATUS_JUDGING, cases, progress });
|
||||
if (data.status < 2) continue;
|
||||
logger.info('RecordID:', id, 'done');
|
||||
// TODO calc total status
|
||||
|
||||
Reference in new issue
Block a user