mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: deprecate ProblemModel.list
This commit is contained in:
3 files changed
+7
-5
No files matched your search
@@ -142,9 +142,9 @@ export class ProblemMainHandler extends Handler {
|
|||||||
// eslint-disable-next-line prefer-const
|
// eslint-disable-next-line prefer-const
|
||||||
let [pdocs, ppcount, pcount] = this.queryContext.fail
|
let [pdocs, ppcount, pcount] = this.queryContext.fail
|
||||||
? [[], 0, 0]
|
? [[], 0, 0]
|
||||||
: await problem.list(
|
: await this.paginate(
|
||||||
domainId, query, sort.length ? 1 : page, limit,
|
problem.getMulti(domainId, query, quick ? ['title', 'pid', 'domainId', 'docId'] : undefined).sort({ sort: 1, docId: 1 }),
|
||||||
quick ? ['title', 'pid', 'domainId', 'docId'] : undefined,
|
sort.length ? 1 : page, limit,
|
||||||
);
|
);
|
||||||
if (total) {
|
if (total) {
|
||||||
pcount = total;
|
pcount = total;
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ export class ProblemModel {
|
|||||||
return document.getMulti(domainId, document.TYPE_PROBLEM, query, projection).sort({ sort: 1 });
|
return document.getMulti(domainId, document.TYPE_PROBLEM, query, projection).sort({ sort: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
static async list(
|
static async list(
|
||||||
domainId: string, query: Filter<ProblemDoc>,
|
domainId: string, query: Filter<ProblemDoc>,
|
||||||
page: number, pageSize: number,
|
page: number, pageSize: number,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ declare module '@hydrooj/framework' {
|
|||||||
domain: DomainDoc;
|
domain: DomainDoc;
|
||||||
|
|
||||||
paginate<T>(cursor: FindCursor<T>, page: number, key: string): Promise<[docs: T[], numPages: number, count: number]>;
|
paginate<T>(cursor: FindCursor<T>, page: number, key: string): Promise<[docs: T[], numPages: number, count: number]>;
|
||||||
|
paginate<T>(cursor: FindCursor<T>, page: number, limit: number): Promise<[docs: T[], numPages: number, count: number]>;
|
||||||
progress(message: string, params: any[]): void;
|
progress(message: string, params: any[]): void;
|
||||||
limitRate(op: string, periodSecs: number, maxOperations: number, defaultKey?: string): Promise<void>;
|
limitRate(op: string, periodSecs: number, maxOperations: number, defaultKey?: string): Promise<void>;
|
||||||
renderTitle(str: string): string;
|
renderTitle(str: string): string;
|
||||||
@@ -237,8 +238,8 @@ export async function apply(ctx: Context) {
|
|||||||
: str.toString().translate(...this.context.acceptsLanguages(), system.get('server.language'));
|
: str.toString().translate(...this.context.acceptsLanguages(), system.get('server.language'));
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
paginate<T>(cursor: FindCursor<T>, page: number, key: string) {
|
paginate<T>(cursor: FindCursor<T>, page: number, key: string | number) {
|
||||||
return db.paginate(cursor, page, this.ctx.setting.get(`pagination.${key}`) || 20);
|
return db.paginate(cursor, page, typeof key === 'number' ? key : (this.ctx.setting.get(`pagination.${key}`) || 20));
|
||||||
},
|
},
|
||||||
checkPerm(...args: bigint[]) {
|
checkPerm(...args: bigint[]) {
|
||||||
if (!this.user.hasPerm(...args)) {
|
if (!this.user.hasPerm(...args)) {
|
||||||
|
|||||||
Reference in new issue
Block a user