mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: fix contest storage get
This commit is contained in:
1 parent
836530ad56
commit
9716e7caa2
3 files changed
+9
-4
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user