mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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",
|
"name": "hydrooj",
|
||||||
"version": "2.36.8",
|
"version": "2.36.9",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ import domain from '../model/domain';
|
|||||||
import message from '../model/message';
|
import message from '../model/message';
|
||||||
import problem from '../model/problem';
|
import problem from '../model/problem';
|
||||||
import record from '../model/record';
|
import record from '../model/record';
|
||||||
|
import storage from '../model/storage';
|
||||||
import * as system from '../model/system';
|
import * as system from '../model/system';
|
||||||
import user from '../model/user';
|
import user from '../model/user';
|
||||||
import * as bus from '../service/bus';
|
import * as bus from '../service/bus';
|
||||||
import {
|
import {
|
||||||
Handler, param, Route, Types,
|
Handler, param, Route, Types,
|
||||||
} from '../service/server';
|
} from '../service/server';
|
||||||
import storage from '../service/storage';
|
|
||||||
|
|
||||||
export class ContestListHandler extends Handler {
|
export class ContestListHandler extends Handler {
|
||||||
@param('rule', Types.Range(contest.RULES), true)
|
@param('rule', Types.Range(contest.RULES), true)
|
||||||
|
|||||||
@@ -45,10 +45,15 @@ class RecordListHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (uidOrName) {
|
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;
|
if (udoc) q.uid = udoc._id;
|
||||||
else invalid = true;
|
else invalid = true;
|
||||||
}
|
}
|
||||||
|
if (pid && tdoc && /^[A-Z]$/.test(pid)) {
|
||||||
|
pid = tdoc.pids[parseInt(pid, 36) - 10];
|
||||||
|
}
|
||||||
if (pid) {
|
if (pid) {
|
||||||
const pdoc = await problem.get(domainId, pid);
|
const pdoc = await problem.get(domainId, pid);
|
||||||
if (pdoc) q.pid = pdoc.docId;
|
if (pdoc) q.pid = pdoc.docId;
|
||||||
@@ -62,7 +67,7 @@ class RecordListHandler extends Handler {
|
|||||||
if (!full) cursor = cursor.project(buildProjection(record.PROJECTION_LIST));
|
if (!full) cursor = cursor.project(buildProjection(record.PROJECTION_LIST));
|
||||||
const limit = full ? 10 : system.get('pagination.record');
|
const limit = full ? 10 : system.get('pagination.record');
|
||||||
const rdocs = invalid
|
const rdocs = invalid
|
||||||
? [[] as RecordDoc[]]
|
? [] as RecordDoc[]
|
||||||
: await cursor.skip((page - 1) * limit).limit(limit).toArray();
|
: await cursor.skip((page - 1) * limit).limit(limit).toArray();
|
||||||
const canViewProblem = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM);
|
const canViewProblem = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM);
|
||||||
const canViewProblemHidden = (!!tid) || this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
const canViewProblemHidden = (!!tid) || this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
|
|||||||
Reference in new issue
Block a user