mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-21 01:46:28 +08:00
core: contest.list: ignore hidden rule
This commit is contained in:
1 parent
81cf7247d8
commit
b3555e030f
2 files changed
+8
-4
No files matched your search
@@ -5,8 +5,9 @@ import moment from 'moment-timezone';
|
|||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import { sortFiles, Time } from '@hydrooj/utils/lib/utils';
|
import { sortFiles, Time } from '@hydrooj/utils/lib/utils';
|
||||||
import {
|
import {
|
||||||
ContestNotFoundError, ContestNotLiveError, ForbiddenError, InvalidTokenError,
|
BadRequestError, ContestNotFoundError, ContestNotLiveError,
|
||||||
PermissionError, ValidationError,
|
ForbiddenError, InvalidTokenError, PermissionError,
|
||||||
|
ValidationError,
|
||||||
} from '../error';
|
} from '../error';
|
||||||
import { Tdoc } from '../interface';
|
import { Tdoc } from '../interface';
|
||||||
import paginate from '../lib/paginate';
|
import paginate from '../lib/paginate';
|
||||||
@@ -69,7 +70,9 @@ export class ContestListHandler extends Handler {
|
|||||||
@param('rule', Types.Range(contest.RULES), true)
|
@param('rule', Types.Range(contest.RULES), true)
|
||||||
@param('page', Types.PositiveInt, true)
|
@param('page', Types.PositiveInt, true)
|
||||||
async get(domainId: string, rule = '', page = 1) {
|
async get(domainId: string, rule = '', page = 1) {
|
||||||
const cursor = contest.getMulti(domainId, rule ? { rule } : { rule: { $ne: 'homework' } });
|
if (rule && contest.RULES[rule].hidden) throw new BadRequestError();
|
||||||
|
const rules = Object.keys(contest.RULES).filter((i) => !contest.RULES[i].hidden);
|
||||||
|
const cursor = contest.getMulti(domainId, rule ? { rule } : { rule: { $in: rules } });
|
||||||
const qs = rule ? `rule=${rule}` : '';
|
const qs = rule ? `rule=${rule}` : '';
|
||||||
const [tdocs, tpcount] = await paginate<Tdoc>(cursor, page, system.get('pagination.contest'));
|
const [tdocs, tpcount] = await paginate<Tdoc>(cursor, page, system.get('pagination.contest'));
|
||||||
const tids = [];
|
const tids = [];
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ export class HomeHandler extends Handler {
|
|||||||
|
|
||||||
async getContest(domainId: string, limit = 10) {
|
async getContest(domainId: string, limit = 10) {
|
||||||
if (this.user.hasPerm(PERM.PERM_VIEW_CONTEST)) {
|
if (this.user.hasPerm(PERM.PERM_VIEW_CONTEST)) {
|
||||||
const tdocs = await contest.getMulti(domainId, { rule: { $ne: 'homework' } })
|
const rules = Object.keys(contest.RULES).filter((i) => !contest.RULES[i].hidden);
|
||||||
|
const tdocs = await contest.getMulti(domainId, { rule: { $in: rules } })
|
||||||
.limit(limit).toArray();
|
.limit(limit).toArray();
|
||||||
const tsdict = await contest.getListStatus(
|
const tsdict = await contest.getListStatus(
|
||||||
domainId, this.user._id, tdocs.map((tdoc) => tdoc.docId),
|
domainId, this.user._id, tdocs.map((tdoc) => tdoc.docId),
|
||||||
|
|||||||
Reference in new issue
Block a user