core: fix contest storage get

This commit is contained in:
undefined committed 2021-09-20 18:08:50 +08:00
1 parent 836530ad56
commit 9716e7caa2
3 files changed
+9 -4

No files matched your search

+7 -2
View File
@@ -45,10 +45,15 @@ class RecordListHandler extends Handler {
}
}
if (uidOrName) {
const udoc = await user.getById(domainId, +uidOrName) ?? await user.getByUname(domainId, uidOrName);
const udoc = await user.getById(domainId, +uidOrName)
|| await user.getByUname(domainId, uidOrName)
|| await user.getByEmail(domainId, uidOrName);
if (udoc) q.uid = udoc._id;
else invalid = true;
}
if (pid && tdoc && /^[A-Z]$/.test(pid)) {
pid = tdoc.pids[parseInt(pid, 36) - 10];
}
if (pid) {
const pdoc = await problem.get(domainId, pid);
if (pdoc) q.pid = pdoc.docId;
@@ -62,7 +67,7 @@ class RecordListHandler extends Handler {
if (!full) cursor = cursor.project(buildProjection(record.PROJECTION_LIST));
const limit = full ? 10 : system.get('pagination.record');
const rdocs = invalid
? [[] as RecordDoc[]]
? [] as RecordDoc[]
: await cursor.skip((page - 1) * limit).limit(limit).toArray();
const canViewProblem = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM);
const canViewProblemHidden = (!!tid) || this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);