Fixed #2338 -> Slow opening of big boards with too many archived items

This commit is contained in:
wekan 2019-05-13 11:01:50 +02:00
parent b983479476
commit ab4fec0f3c
8 changed files with 92 additions and 64 deletions

View file

@ -59,9 +59,12 @@ Meteor.publish('archivedBoards', function() {
});
});
Meteor.publishRelations('board', function(boardId) {
// If isArchived = false, this will only return board elements which are not archived.
// If isArchived = true, this will only return board elements which are archived.
Meteor.publishRelations('board', function(boardId, isArchived) {
this.unblock();
check(boardId, String);
check(isArchived, Boolean);
const thisUserId = this.userId;
this.cursor(Boards.find({
@ -75,8 +78,8 @@ Meteor.publishRelations('board', function(boardId) {
],
// Sort required to ensure oplog usage
}, { limit: 1, sort: { _id: 1 } }), function(boardId, board) {
this.cursor(Lists.find({ boardId }));
this.cursor(Swimlanes.find({ boardId }));
this.cursor(Lists.find({ boardId: boardId, archived: isArchived }));
this.cursor(Swimlanes.find({ boardId: boardId, archived: isArchived }));
this.cursor(Integrations.find({ boardId }));
this.cursor(CustomFields.find({ boardIds: {$in: [boardId]} }, { sort: { name: 1 } }));
@ -115,8 +118,9 @@ Meteor.publishRelations('board', function(boardId) {
parentCards.selector = (_ids) => ({ parentId: _ids });
const boards = this.join(Boards);
const subCards = this.join(Cards);
subCards.selector = (_ids) => ({ archived: isArchived });
this.cursor(Cards.find({ boardId: {$in: [boardId, board.subtasksDefaultBoardId]}}), function(cardId, card) {
this.cursor(Cards.find({ boardId: {$in: [boardId, board.subtasksDefaultBoardId]}, archived: isArchived }), function(cardId, card) {
if (card.type === 'cardType-linkedCard') {
const impCardId = card.linkedId;
subCards.push(impCardId);