mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: bug fix
This commit is contained in:
1 parent
1b11e6bcbb
commit
3daafe5396
3 files changed
+36
-28
No files matched your search
@@ -94,12 +94,17 @@ export class ContestDetailHandler extends Handler {
|
||||
@param('tid', Types.ObjectID)
|
||||
@param('page', Types.PositiveInt, true)
|
||||
async get(domainId: string, tid: ObjectID, page = 1) {
|
||||
const tdoc = await contest.get(domainId, tid);
|
||||
this.response.template = 'contest_detail.html';
|
||||
const [tsdoc, pdict] = await Promise.all([
|
||||
contest.getStatus(domainId, tdoc.docId, this.user._id),
|
||||
problem.getList(domainId, tdoc.pids, true),
|
||||
const [tdoc, tsdoc] = await Promise.all([
|
||||
contest.get(domainId, tid),
|
||||
contest.getStatus(domainId, tid, this.user._id),
|
||||
]);
|
||||
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 = {};
|
||||
let rdict = {};
|
||||
if (tsdoc) {
|
||||
@@ -112,10 +117,9 @@ export class ContestDetailHandler extends Handler {
|
||||
for (const i in psdict) rdict[psdict[i].rid] = { _id: psdict[i].rid };
|
||||
}
|
||||
}
|
||||
const udict = await user.getList(domainId, [tdoc.owner]);
|
||||
this.response.body = {
|
||||
tdoc, tsdoc, udict, pdict, psdict, rdict, page,
|
||||
};
|
||||
this.response.body.pdict = pdict;
|
||||
this.response.body.psdict = psdict;
|
||||
this.response.body.rdict = rdict;
|
||||
}
|
||||
|
||||
@param('tid', Types.ObjectID)
|
||||
|
||||
@@ -55,12 +55,26 @@ class HomeworkDetailHandler extends Handler {
|
||||
@param('tid', Types.ObjectID)
|
||||
@param('page', Types.PositiveInt, true)
|
||||
async get(domainId: string, tid: ObjectID, page = 1) {
|
||||
const tdoc = await contest.get(domainId, tid);
|
||||
if (tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid);
|
||||
const [tsdoc, pdict] = await Promise.all([
|
||||
contest.getStatus(domainId, tdoc.docId, this.user._id),
|
||||
problem.getList(domainId, tdoc.pids, true),
|
||||
const [tdoc, tsdoc] = await Promise.all([
|
||||
contest.get(domainId, tid),
|
||||
contest.getStatus(domainId, tid, this.user._id),
|
||||
]);
|
||||
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 = {};
|
||||
let rdict = {};
|
||||
if (tsdoc) {
|
||||
@@ -75,19 +89,9 @@ class HomeworkDetailHandler extends Handler {
|
||||
);
|
||||
}
|
||||
}
|
||||
// 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, pdict, psdict, rdict, ddocs, page, dpcount, dcount,
|
||||
};
|
||||
this.response.body.pdict = pdict;
|
||||
this.response.body.psdict = psdict;
|
||||
this.response.body.rdict = rdict;
|
||||
}
|
||||
|
||||
@param('tid', Types.ObjectID)
|
||||
|
||||
Reference in new issue
Block a user