Merge pull request #4074 from mfilser/global_search_checklistitems_and_customFields_boolean

Global search checklistitems and custom fields boolean
This commit is contained in:
Lauri Ojansivu 2021-10-25 18:01:10 +03:00 committed by GitHub
commit 18ff4bee2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -404,7 +404,7 @@ function buildSelector(queryParams) {
const items = ChecklistItems.find( const items = ChecklistItems.find(
{ title: regex }, { title: regex },
{ fields: { cardId: 1 } }, { fields: { cardId: 1, checklistId: 1 } },
); );
const checklists = Checklists.find( const checklists = Checklists.find(
{ {
@ -423,23 +423,18 @@ function buildSelector(queryParams) {
{ fields: { cardId: 1 } }, { fields: { cardId: 1 } },
); );
selector.$and.push({ let cardsSelector = [
$or: [
{ title: regex }, { title: regex },
{ description: regex }, { description: regex },
{ customFields: { $elemMatch: { value: regex } } }, { customFields: { $elemMatch: { value: regex } } },
// {
// _id: {
// $in: CardComments.textSearch(userId, [queryParams.text]).map(
// com => com.cardId,
// ),
// },
// },
{ _id: { $in: checklists.map(list => list.cardId) } }, { _id: { $in: checklists.map(list => list.cardId) } },
{ _id: { $in: attachments.map(attach => attach.cardId) } }, { _id: { $in: attachments.map(attach => attach.cardId) } },
{ _id: { $in: comments.map(com => com.cardId) } }, { _id: { $in: comments.map(com => com.cardId) } },
], ];
}); if (queryParams.text == "false" || queryParams.text == "true") {
cardsSelector.push({ customFields: { $elemMatch: { value: queryParams.text == "true" ? true : false } } } );
}
selector.$and.push({ $or: cardsSelector });
} }
if (selector.$and.length === 0) { if (selector.$and.length === 0) {
@ -448,9 +443,7 @@ function buildSelector(queryParams) {
} }
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('selector:', selector); console.log('cards selector:', JSON.stringify(selector, null, 2));
// eslint-disable-next-line no-console
console.log('selector.$and:', selector.$and);
const query = new Query(); const query = new Query();
query.selector = selector; query.selector = selector;
@ -610,7 +603,7 @@ function findCards(sessionId, query) {
// console.log('selector:', query.selector); // console.log('selector:', query.selector);
// console.log('selector.$and:', query.selector.$and); // console.log('selector.$and:', query.selector.$and);
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
// console.log('projection:', projection); // console.log('projection:', query.projection);
const cards = Cards.find(query.selector, query.projection); const cards = Cards.find(query.selector, query.projection);
// eslint-disable-next-line no-console // eslint-disable-next-line no-console