core: allow searching tags

pull/579/head
undefined 1 year ago
parent cfb6accffa
commit 00542e067f
No known key found for this signature in database

@ -114,8 +114,8 @@ function buildQuery(udoc: User) {
const defaultSearch = async (domainId: string, q: string, options?: ProblemSearchOptions) => { const defaultSearch = async (domainId: string, q: string, options?: ProblemSearchOptions) => {
const escaped = escapeRegExp(q.toLowerCase()); const escaped = escapeRegExp(q.toLowerCase());
const $regex = new RegExp(q.length >= 3 ? escaped : `\\A${escaped}`, 'gmi'); const $regex = new RegExp(q.length >= 2 ? escaped : `\\A${escaped}`, 'gmi');
const filter = { $or: [{ pid: { $regex } }, { title: { $regex } }] }; const filter = { $or: [{ pid: { $regex } }, { title: { $regex } }, { tag: q }] };
const pdocs = await problem.getMulti(domainId, filter, ['domainId', 'docId', 'pid']) const pdocs = await problem.getMulti(domainId, filter, ['domainId', 'docId', 'pid'])
.skip(options.skip || 0).limit(options.limit || system.get('pagination.problem')).toArray(); .skip(options.skip || 0).limit(options.limit || system.get('pagination.problem')).toArray();
if (!Number.isNaN(+q)) { if (!Number.isNaN(+q)) {

Loading…
Cancel
Save