From 20415b881c79880039971f2d0854213871bf9673 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 21 Oct 2021 13:19:17 +0200 Subject: [PATCH 1/3] Board search, removed limit of 10 cards --- models/boards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/boards.js b/models/boards.js index de2a87746..eb21973db 100644 --- a/models/boards.js +++ b/models/boards.js @@ -974,7 +974,7 @@ Boards.helpers({ } else { query.type = { $nin: ['template-card'] }; } - const projection = { limit: 10, sort: { createdAt: -1 } }; + const projection = { sort: { createdAt: -1 } }; if (term) { const regex = new RegExp(term, 'i'); From 5eb4cff991274eada543ebf726f518de5cf560c8 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 21 Oct 2021 13:20:10 +0200 Subject: [PATCH 2/3] Board search, remove limit of 10 lists --- models/boards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/boards.js b/models/boards.js index eb21973db..cdf0d9f6d 100644 --- a/models/boards.js +++ b/models/boards.js @@ -950,7 +950,7 @@ Boards.helpers({ } else { query.type = { $nin: ['template-list'] }; } - const projection = { limit: 10, sort: { createdAt: -1 } }; + const projection = { sort: { createdAt: -1 } }; if (term) { const regex = new RegExp(term, 'i'); From 4521d5c10d47500e341b79d2c83de2cf45087b50 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 21 Oct 2021 23:07:33 +0200 Subject: [PATCH 3/3] Search cards, dont't search on empty search term - otherwise all cards / lists are returned, and at big boards it will take a long time to load all cards / lists --- models/boards.js | 71 +++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/models/boards.js b/models/boards.js index cdf0d9f6d..43377bfb8 100644 --- a/models/boards.js +++ b/models/boards.js @@ -941,42 +941,51 @@ Boards.helpers({ }, searchLists(term) { - check(term, Match.OneOf(String, null, undefined)); - - const query = { boardId: this._id }; - if (this.isTemplatesBoard()) { - query.type = 'template-list'; - query.archived = false; - } else { - query.type = { $nin: ['template-list'] }; - } - const projection = { sort: { createdAt: -1 } }; - + let ret = null; if (term) { - const regex = new RegExp(term, 'i'); - - query.$or = [{ title: regex }, { description: regex }]; + check(term, Match.OneOf(String)); + term = term.trim(); } + if (term) { + const query = { boardId: this._id }; + if (this.isTemplatesBoard()) { + query.type = 'template-list'; + query.archived = false; + } else { + query.type = { $nin: ['template-list'] }; + } + const projection = { sort: { createdAt: -1 } }; - return Lists.find(query, projection); + if (term) { + const regex = new RegExp(term, 'i'); + + query.$or = [{ title: regex }, { description: regex }]; + } + + ret = Lists.find(query, projection); + } + return ret; }, searchCards(term, excludeLinked) { - check(term, Match.OneOf(String, null, undefined)); - - const query = { boardId: this._id }; - if (excludeLinked) { - query.linkedId = null; - } - if (this.isTemplatesBoard()) { - query.type = 'template-card'; - query.archived = false; - } else { - query.type = { $nin: ['template-card'] }; - } - const projection = { sort: { createdAt: -1 } }; - + let ret = null; if (term) { + check(term, Match.OneOf(String)); + term = term.trim(); + } + if (term) { + const query = { boardId: this._id }; + if (excludeLinked) { + query.linkedId = null; + } + if (this.isTemplatesBoard()) { + query.type = 'template-card'; + query.archived = false; + } else { + query.type = { $nin: ['template-card'] }; + } + const projection = { sort: { createdAt: -1 } }; + const regex = new RegExp(term, 'i'); query.$or = [ @@ -984,9 +993,9 @@ Boards.helpers({ { description: regex }, { customFields: { $elemMatch: { value: regex } } }, ]; + ret = Cards.find(query, projection); } - - return Cards.find(query, projection); + return ret; }, // A board alwasy has another board where it deposits subtasks of thasks // that belong to itself.