Files
wekan/server/publications/boardTextMatches.js
T
Lauri Ojansivu c17305c2e8 Filter cards by recorded historical movement dates
Match any recorded list, swimlane or incoming board move within inclusive local-day bounds, regardless of later moves. Reuse the authorized reactive ID publication for text and history, preserve lazy-loading coverage and validate history joins and live UI behavior.

Thanks to neooleg and xet7 !
2026-09-28 18:19:22 +03:00

26 lines
1.2 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Cards from '/models/cards';
import CardComments from '/models/cardComments';
import Checklists from '/models/checklists';
import ChecklistItems from '/models/checklistItems';
import { boardTextSearch } from '/server/lib/boardTextSearch';
import { publishBoardMatches } from '/server/lib/publishBoardMatches';
Meteor.publish('boardTextMatches', async function(boardId, term) {
check(boardId, String); check(term, String);
if (!boardId || !term.trim() || term.length > 512) return this.ready();
const sources = [
{ model: CardComments, field: 'text' },
{ model: Checklists, field: 'title' },
{ model: ChecklistItems, field: 'title' },
];
return publishBoardMatches({ publication: this, boardId, key: term, identity: { term },
collectionName: 'boardTextMatches', cardFields: { title: 1, description: 1 },
children: sources.map(({ model, field }) => ({ model, fields: { [field]: 1 } })),
findMatches: ({ scope, stopped }) => boardTextSearch({ cards: Cards.rawCollection(),
children: sources.map(({ model, field }) => ({ collection: model.rawCollection(), field })),
scope, term, stopped }),
});
});