mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: move hack to record/judge
This commit is contained in:
2 files changed
+8
-8
No files matched your search
@@ -98,14 +98,17 @@ export async function postJudge(rdoc: RecordDoc) {
|
|||||||
const pdoc = (accept && updated)
|
const pdoc = (accept && updated)
|
||||||
? await problem.inc(rdoc.domainId, rdoc.pid, 'nAccept', 1)
|
? await problem.inc(rdoc.domainId, rdoc.pid, 'nAccept', 1)
|
||||||
: await problem.get(rdoc.domainId, rdoc.pid, undefined, true);
|
: await problem.get(rdoc.domainId, rdoc.pid, undefined, true);
|
||||||
if (pdoc) {
|
if (pdoc && isNormalSubmission) {
|
||||||
if (isNormalSubmission) {
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
problem.inc(pdoc.domainId, pdoc.docId, `stats.${builtin.STATUS_SHORT_TEXTS[rdoc.status]}`, 1),
|
problem.inc(pdoc.domainId, pdoc.docId, `stats.${builtin.STATUS_SHORT_TEXTS[rdoc.status]}`, 1),
|
||||||
problem.inc(pdoc.domainId, pdoc.docId, `stats.s${Math.floor(rdoc.score)}`, 1),
|
problem.inc(pdoc.domainId, pdoc.docId, `stats.s${Math.floor(rdoc.score)}`, 1),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if (rdoc.status === STATUS.STATUS_HACK_SUCCESSFUL) {
|
await bus.parallel('record/judge', rdoc, updated, pdoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
bus.on('record/judge', async (rdoc, updated, pdoc) => {
|
||||||
|
if (!pdoc || rdoc.status !== STATUS.STATUS_HACK_SUCCESSFUL) return;
|
||||||
try {
|
try {
|
||||||
const config = yaml.load(pdoc.config as string) as ProblemConfigFile;
|
const config = yaml.load(pdoc.config as string) as ProblemConfigFile;
|
||||||
assert(config.subtasks instanceof Array);
|
assert(config.subtasks instanceof Array);
|
||||||
@@ -135,10 +138,7 @@ export async function postJudge(rdoc: RecordDoc) {
|
|||||||
message: { message: 'Unable to apply hack: {0}', params: [e.message] },
|
message: { message: 'Unable to apply hack: {0}', params: [e.message] },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
await bus.parallel('record/judge', rdoc, updated);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function end(body: Partial<JudgeResultBody>) {
|
export async function end(body: Partial<JudgeResultBody>) {
|
||||||
body.rid = new ObjectId(body.rid); // TODO remove this
|
body.rid = new ObjectId(body.rid); // TODO remove this
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export interface EventMap extends LifecycleEvents, HandlerEvents {
|
|||||||
'training/get': (tdoc: TrainingDoc, handler: any) => VoidReturn
|
'training/get': (tdoc: TrainingDoc, handler: any) => VoidReturn
|
||||||
|
|
||||||
'record/change': (rdoc: RecordDoc, $set?: any, $push?: any, body?: any) => void
|
'record/change': (rdoc: RecordDoc, $set?: any, $push?: any, body?: any) => void
|
||||||
'record/judge': (rdoc: RecordDoc, updated: boolean) => VoidReturn
|
'record/judge': (rdoc: RecordDoc, updated: boolean, pdoc?: ProblemDoc) => VoidReturn
|
||||||
}
|
}
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user