core: deprecate ProblemModel.list

This commit is contained in:
undefined committed 2024-10-22 10:28:00 +08:00
1 parent 7d9df55d09
commit eb26feb655
3 files changed
+7 -5

No files matched your search

+3 -3
View File
@@ -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;
+1
View File
@@ -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,
+3 -2
View File
@@ -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)) {