core: fix contest storage get

pull/220/head
undefined 3 years ago
parent 836530ad56
commit 9716e7caa2

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.36.8",
"version": "2.36.9",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",

@ -20,13 +20,13 @@ import domain from '../model/domain';
import message from '../model/message';
import problem from '../model/problem';
import record from '../model/record';
import storage from '../model/storage';
import * as system from '../model/system';
import user from '../model/user';
import * as bus from '../service/bus';
import {
Handler, param, Route, Types,
} from '../service/server';
import storage from '../service/storage';
export class ContestListHandler extends Handler {
@param('rule', Types.Range(contest.RULES), true)

@ -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);

Loading…
Cancel
Save