mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: ensure testcase order
This commit is contained in:
1 parent
098e681d79
commit
b3de1a4247
8 files changed
+30
-71
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user