修复在线IDE

This commit is contained in:
masnn committed 2020-04-17 18:09:41 +08:00
1 parent b1153b641a
commit 61cba6f180
12 files changed
+94 -76

No files matched your search

+7 -5
View File
@@ -92,10 +92,11 @@ class JudgeHandler extends Handler {
async get({ check = false }) {
this.response.body = {};
if (check) return;
const rid = await queue.get('judge', false);
if (rid) {
const rdoc = await record.get(rid);
const pdoc = await problem.getById(rdoc.pid);
const tasks = [];
let rid = await queue.get('judge', false);
while (rid) {
const rdoc = await record.get(rid); // eslint-disable-line no-await-in-loop
const pdoc = await problem.getById(rdoc.pid); // eslint-disable-line no-await-in-loop
const task = {
event: 'judge',
rid,
@@ -105,7 +106,8 @@ class JudgeHandler extends Handler {
lang: rdoc.lang,
code: rdoc.code,
};
this.response.body = { task };
tasks.push(task);
rid = await queue.get('judge', false); // eslint-disable-line no-await-in-loop
}
}
+6 -9
View File
@@ -32,8 +32,7 @@ class UserLoginHandler extends Handler {
}
}
class UserLogoutHandler extends Handler {
constructor(ctx) {
super(ctx);
async prepare() {
this.checkPerm(PERM_LOGGEDIN);
}
@@ -47,8 +46,7 @@ class UserLogoutHandler extends Handler {
}
}
class UserRegisterHandler extends Handler {
constructor(ctx) {
super(ctx);
async prepare() {
this.checkPerm(PERM_REGISTER_USER);
}
@@ -76,8 +74,7 @@ class UserRegisterHandler extends Handler {
}
}
class UserRegisterWithCodeHandler extends Handler {
constructor(ctx) {
super(ctx);
async prepare() {
this.checkPerm(PERM_REGISTER_USER);
}
@@ -153,11 +150,11 @@ class UserDetailHandler extends Handler {
}
async get({ uid }) {
const isSelfProfile = this.ctx.state.user._id === uid;
const isSelfProfile = this.user._id === uid;
const udoc = await user.getById(uid);
if (!udoc) throw new UserNotFoundError(uid);
const sdoc = await token.getMostRecentSessionByUid(uid);
this.ctx.body = { isSelfProfile, udoc, sdoc };
this.response.body = { isSelfProfile, udoc, sdoc };
}
}
class UserSearchHandler extends Handler {
@@ -176,7 +173,7 @@ class UserSearchHandler extends Handler {
udocs[i].gravatar_url = misc.gravatar_url[udocs[i].gravatar];
}
}
this.ctx.body = { udocs };
this.response.body = { udocs };
}
}