ui: ensure testcase order

This commit is contained in:
undefined committed 2021-10-15 19:43:07 +08:00
1 parent 098e681d79
commit b3de1a4247
8 files changed
+30 -71

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.11.9",
"version": "2.11.10",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
+2 -20
View File
@@ -39,8 +39,6 @@ class JudgeTask {
data: any[];
folder: string;
config: any;
nextId = 1;
nextWaiting = [];
getLang: (name: string) => LangConfig;
constructor(session: Hydro, request, ws: WebSocket) {
@@ -135,30 +133,14 @@ class JudgeTask {
delete data.judge_text;
if (data.case) {
data.case = {
id,
status: data.case.status,
time: data.case.time_ms || data.case.time,
memory: data.case.memory_kb || data.case.memory,
message: data.case.message || data.case.judgeText || data.case.judge_text || '',
};
}
if (id) {
if (id === this.nextId) {
this.ws.send(JSON.stringify(data));
this.nextId++;
let t = true;
while (t) {
t = false;
for (const i in this.nextWaiting) {
if (this.nextId === this.nextWaiting[i].id) {
this.ws.send(JSON.stringify(this.nextWaiting[i].data));
this.nextId++;
this.nextWaiting.splice(+i, 1);
t = true;
}
}
}
} else this.nextWaiting.push({ data, id });
} else this.ws.send(JSON.stringify(data));
this.ws.send(JSON.stringify(data));
}
end(data) {
+2 -20
View File
@@ -100,8 +100,6 @@ async function postInit() {
}
function getNext(that) {
that.nextId = 1;
that.nextWaiting = [];
return (data, id = 0) => {
logger.debug('Next: %d %o', id, data);
data.rid = new ObjectID(that.rid);
@@ -113,30 +111,14 @@ async function postInit() {
delete data.compiler_text;
if (data.case) {
data.case = {
id,
status: data.case.status,
time: data.case.time_ms || data.case.time,
memory: data.case.memory_kb || data.case.memory,
message: data.case.message || data.case.judgeText || '',
};
}
if (id) {
if (id === that.nextId) {
_judge.next(data);
that.nextId++;
let t = true;
while (t) {
t = false;
for (const i in that.nextWaiting) {
if (that.nextId === that.nextWaiting[i].id) {
_judge.next(that.nextWaiting[i].data);
that.nextId++;
that.nextWaiting.splice(i, 1);
t = true;
}
}
}
} else that.nextWaiting.push({ data, id });
} else _judge.next(data);
_judge.next(data);
};
}