mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: allow modification of problem list page sort
This commit is contained in:
2 files changed
+4
-4
No files matched your search
@@ -141,7 +141,7 @@ export class ProblemMainHandler extends Handler {
|
|||||||
const query = buildQuery(this.user);
|
const query = buildQuery(this.user);
|
||||||
const psdict = {};
|
const psdict = {};
|
||||||
const search = global.Hydro.lib.problemSearch || defaultSearch;
|
const search = global.Hydro.lib.problemSearch || defaultSearch;
|
||||||
let sort: string[];
|
let sort: string[] = [];
|
||||||
let fail = false;
|
let fail = false;
|
||||||
let pcountRelation = 'eq';
|
let pcountRelation = 'eq';
|
||||||
const parsed = parser.parse(q, {
|
const parsed = parser.parse(q, {
|
||||||
@@ -173,7 +173,7 @@ export class ProblemMainHandler extends Handler {
|
|||||||
});
|
});
|
||||||
sort = result.hits;
|
sort = result.hits;
|
||||||
}
|
}
|
||||||
await this.ctx.parallel('problem/list', query, this);
|
await this.ctx.parallel('problem/list', query, this, sort);
|
||||||
// eslint-disable-next-line prefer-const
|
// eslint-disable-next-line prefer-const
|
||||||
let [pdocs, ppcount, pcount] = fail
|
let [pdocs, ppcount, pcount] = fail
|
||||||
? [[], 0, 0]
|
? [[], 0, 0]
|
||||||
@@ -182,7 +182,7 @@ export class ProblemMainHandler extends Handler {
|
|||||||
pcount = total;
|
pcount = total;
|
||||||
ppcount = Math.ceil(total / limit);
|
ppcount = Math.ceil(total / limit);
|
||||||
}
|
}
|
||||||
if (sort) pdocs = pdocs.sort((a, b) => sort.indexOf(`${a.domainId}/${a.docId}`) - sort.indexOf(`${b.domainId}/${b.docId}`));
|
if (sort.length) pdocs = pdocs.sort((a, b) => sort.indexOf(`${a.domainId}/${a.docId}`) - sort.indexOf(`${b.domainId}/${b.docId}`));
|
||||||
if (q && page === 1) {
|
if (q && page === 1) {
|
||||||
const pdoc = await problem.get(domainId, +q || q, problem.PROJECTION_LIST);
|
const pdoc = await problem.get(domainId, +q || q, problem.PROJECTION_LIST);
|
||||||
if (pdoc && problem.canViewBy(pdoc, this.user)) {
|
if (pdoc && problem.canViewBy(pdoc, this.user)) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export interface EventMap extends LifecycleEvents, HandlerEvents {
|
|||||||
'problem/edit': (doc: ProblemDoc) => VoidReturn
|
'problem/edit': (doc: ProblemDoc) => VoidReturn
|
||||||
'problem/before-del': (domainId: string, docId: number) => VoidReturn
|
'problem/before-del': (domainId: string, docId: number) => VoidReturn
|
||||||
'problem/del': (domainId: string, docId: number) => VoidReturn
|
'problem/del': (domainId: string, docId: number) => VoidReturn
|
||||||
'problem/list': (query: Filter<ProblemDoc>, handler: any) => VoidReturn
|
'problem/list': (query: Filter<ProblemDoc>, handler: any, sort?: string[]) => VoidReturn
|
||||||
'problem/get': (doc: ProblemDoc, handler: any) => VoidReturn
|
'problem/get': (doc: ProblemDoc, handler: any) => VoidReturn
|
||||||
'problem/delete': (domainId: string, docId: number) => VoidReturn
|
'problem/delete': (domainId: string, docId: number) => VoidReturn
|
||||||
'problem/addTestdata': (domainId: string, docId: number, name: string, payload: Omit<FileInfo, '_id'>) => VoidReturn
|
'problem/addTestdata': (domainId: string, docId: number, name: string, payload: Omit<FileInfo, '_id'>) => VoidReturn
|
||||||
|
|||||||
Reference in new issue
Block a user