core: 整合tag与category

This commit is contained in:
undefined committed 2021-03-07 14:25:16 +08:00
1 parent 454afbcb08
commit 7a41fecb0e
15 files changed
+116 -117

No files matched your search

+1 -8
View File
@@ -30,14 +30,7 @@ export class QueryProblemSetAPIHandler extends Handler {
}
const query: FilterQuery<Pdoc> = {};
if ($search) query.$text = { $search };
if (tags?.length) {
query.$and = tags.map(($eq) => ({
$or: [
{ category: { $elemMatch: { $eq } } },
{ tag: { $elemMatch: { $eq } } },
],
}));
}
if (tags?.length) query.$and = tags.map((tag) => ({ tag }));
if (owner) query.owner = owner;
if (!nonpublic) query.hidden = false;
const [raw, count] = await Promise.all([