mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +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
|
||||
let [pdocs, ppcount, pcount] = this.queryContext.fail
|
||||
? [[], 0, 0]
|
||||
: await problem.list(
|
||||
domainId, query, sort.length ? 1 : page, limit,
|
||||
quick ? ['title', 'pid', 'domainId', 'docId'] : undefined,
|
||||
: await this.paginate(
|
||||
problem.getMulti(domainId, query, quick ? ['title', 'pid', 'domainId', 'docId'] : undefined).sort({ sort: 1, docId: 1 }),
|
||||
sort.length ? 1 : page, limit,
|
||||
);
|
||||
if (total) {
|
||||
pcount = total;
|
||||
|
||||
@@ -192,6 +192,7 @@ export class ProblemModel {
|
||||
return document.getMulti(domainId, document.TYPE_PROBLEM, query, projection).sort({ sort: 1 });
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
static async list(
|
||||
domainId: string, query: Filter<ProblemDoc>,
|
||||
page: number, pageSize: number,
|
||||
|
||||
@@ -32,6 +32,7 @@ declare module '@hydrooj/framework' {
|
||||
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, limit: number): Promise<[docs: T[], numPages: number, count: number]>;
|
||||
progress(message: string, params: any[]): void;
|
||||
limitRate(op: string, periodSecs: number, maxOperations: number, defaultKey?: string): Promise<void>;
|
||||
renderTitle(str: string): string;
|
||||
@@ -237,8 +238,8 @@ export async function apply(ctx: Context) {
|
||||
: str.toString().translate(...this.context.acceptsLanguages(), system.get('server.language'));
|
||||
return res;
|
||||
},
|
||||
paginate<T>(cursor: FindCursor<T>, page: number, key: string) {
|
||||
return db.paginate(cursor, page, this.ctx.setting.get(`pagination.${key}`) || 20);
|
||||
paginate<T>(cursor: FindCursor<T>, page: number, key: string | number) {
|
||||
return db.paginate(cursor, page, typeof key === 'number' ? key : (this.ctx.setting.get(`pagination.${key}`) || 20));
|
||||
},
|
||||
checkPerm(...args: bigint[]) {
|
||||
if (!this.user.hasPerm(...args)) {
|
||||
|
||||
Reference in new issue
Block a user