core: bug fix

This commit is contained in:
undefined committed 2022-02-10 20:32:17 +08:00
1 parent 1b11e6bcbb
commit 3daafe5396
3 files changed
+36 -28

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "3.4.17", "version": "3.4.18",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+13 -9
View File
@@ -94,12 +94,17 @@ export class ContestDetailHandler extends Handler {
@param('tid', Types.ObjectID) @param('tid', Types.ObjectID)
@param('page', Types.PositiveInt, true) @param('page', Types.PositiveInt, true)
async get(domainId: string, tid: ObjectID, page = 1) { async get(domainId: string, tid: ObjectID, page = 1) {
const tdoc = await contest.get(domainId, tid); const [tdoc, tsdoc] = await Promise.all([
this.response.template = 'contest_detail.html'; contest.get(domainId, tid),
const [tsdoc, pdict] = await Promise.all([ contest.getStatus(domainId, tid, this.user._id),
contest.getStatus(domainId, tdoc.docId, this.user._id),
problem.getList(domainId, tdoc.pids, true),
]); ]);
this.response.template = 'contest_detail.html';
const udict = await user.getList(domainId, [tdoc.owner]);
this.response.body = {
tdoc, tsdoc, udict, page,
};
if (contest.isNotStarted(tdoc)) return;
const pdict = await problem.getList(domainId, tdoc.pids, true);
const psdict = {}; const psdict = {};
let rdict = {}; let rdict = {};
if (tsdoc) { if (tsdoc) {
@@ -112,10 +117,9 @@ export class ContestDetailHandler extends Handler {
for (const i in psdict) rdict[psdict[i].rid] = { _id: psdict[i].rid }; for (const i in psdict) rdict[psdict[i].rid] = { _id: psdict[i].rid };
} }
} }
const udict = await user.getList(domainId, [tdoc.owner]); this.response.body.pdict = pdict;
this.response.body = { this.response.body.psdict = psdict;
tdoc, tsdoc, udict, pdict, psdict, rdict, page, this.response.body.rdict = rdict;
};
} }
@param('tid', Types.ObjectID) @param('tid', Types.ObjectID)
+22 -18
View File
@@ -55,12 +55,26 @@ class HomeworkDetailHandler extends Handler {
@param('tid', Types.ObjectID) @param('tid', Types.ObjectID)
@param('page', Types.PositiveInt, true) @param('page', Types.PositiveInt, true)
async get(domainId: string, tid: ObjectID, page = 1) { async get(domainId: string, tid: ObjectID, page = 1) {
const tdoc = await contest.get(domainId, tid); const [tdoc, tsdoc] = await Promise.all([
if (tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid); contest.get(domainId, tid),
const [tsdoc, pdict] = await Promise.all([ contest.getStatus(domainId, tid, this.user._id),
contest.getStatus(domainId, tdoc.docId, this.user._id),
problem.getList(domainId, tdoc.pids, true),
]); ]);
if (tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid);
// discussion
const [ddocs, dpcount, dcount] = await paginate(
discussion.getMulti(domainId, { parentType: tdoc.docType, parentId: tdoc.docId }),
page,
system.get('pagination.discussion'),
);
const uids = ddocs.map((ddoc) => ddoc.owner);
uids.push(tdoc.owner);
const udict = await user.getList(domainId, uids);
this.response.template = 'homework_detail.html';
this.response.body = {
tdoc, tsdoc, udict, ddocs, page, dpcount, dcount,
};
if (contest.isNotStarted(tdoc)) return;
const pdict = await problem.getList(domainId, tdoc.pids, true);
const psdict = {}; const psdict = {};
let rdict = {}; let rdict = {};
if (tsdoc) { if (tsdoc) {
@@ -75,19 +89,9 @@ class HomeworkDetailHandler extends Handler {
); );
} }
} }
// discussion this.response.body.pdict = pdict;
const [ddocs, dpcount, dcount] = await paginate( this.response.body.psdict = psdict;
discussion.getMulti(domainId, { parentType: tdoc.docType, parentId: tdoc.docId }), this.response.body.rdict = rdict;
page,
system.get('pagination.discussion'),
);
const uids = ddocs.map((ddoc) => ddoc.owner);
uids.push(tdoc.owner);
const udict = await user.getList(domainId, uids);
this.response.template = 'homework_detail.html';
this.response.body = {
tdoc, tsdoc, udict, pdict, psdict, rdict, ddocs, page, dpcount, dcount,
};
} }
@param('tid', Types.ObjectID) @param('tid', Types.ObjectID)