core&ui: add problems gql to fix autocomplete (#389)

This commit is contained in:
panda authored and GitHub committed 2022-07-21 20:59:36 +08:00
1 parent 4b3c57549a
commit a52c488e23
5 files changed
+17 -5

No files matched your search

+5
View File
@@ -80,6 +80,11 @@ registerResolver(
return pdoc;
},
);
registerResolver('Query', 'problems(ids: [Int])', '[Problem]', async (arg, ctx) => {
const res = await problem.getList(ctx.args.domainId, arg.ids, ctx.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || ctx.user._id,
ctx.user.group, undefined, undefined, true);
return Object.keys(res).map((id) => res[+id]);
}, 'Get a list of problem by ids');
registerResolver(
'Problem', 'manage', 'ProblemManage',
(arg, ctx) => {
+2 -1
View File
@@ -488,7 +488,8 @@ export async function get(domainId: string, tid: ObjectID): Promise<Tdoc<30>> {
}
export async function getRelated(domainId: string, pid: number) {
return await document.getMulti(domainId, document.TYPE_CONTEST, { pids: pid }).toArray();
const rules = Object.keys(RULES).filter((i) => !RULES[i].hidden);
return await document.getMulti(domainId, document.TYPE_CONTEST, { pids: pid, rule: { $in: rules } }).toArray();
}
export async function getStatus(domainId: string, tid: ObjectID, uid: number) {