summaryrefslogtreecommitdiffstats
path: root/server/publications
diff options
context:
space:
mode:
authorJustin Reynolds <justinr1234@gmail.com>2019-02-28 11:44:29 -0600
committerJustin Reynolds <justinr1234@gmail.com>2019-02-28 11:44:29 -0600
commit3c49e2d0edec19eff4f87b0fcc127f924af193fc (patch)
tree99074349d9befecceaa02b4b8776718591712801 /server/publications
parent904b5bf0f5f6e36131bf2d081a5d08fef408ac81 (diff)
downloadwekan-3c49e2d0edec19eff4f87b0fcc127f924af193fc.tar.gz
wekan-3c49e2d0edec19eff4f87b0fcc127f924af193fc.tar.bz2
wekan-3c49e2d0edec19eff4f87b0fcc127f924af193fc.zip
Performance Enhancements
Diffstat (limited to 'server/publications')
-rw-r--r--server/publications/boards.js49
1 files changed, 37 insertions, 12 deletions
diff --git a/server/publications/boards.js b/server/publications/boards.js
index 71c53612..18c44d2b 100644
--- a/server/publications/boards.js
+++ b/server/publications/boards.js
@@ -60,6 +60,7 @@ Meteor.publish('archivedBoards', function() {
});
Meteor.publishRelations('board', function(boardId) {
+ this.unblock();
check(boardId, String);
const thisUserId = this.userId;
@@ -72,7 +73,8 @@ Meteor.publishRelations('board', function(boardId) {
{ permission: 'public' },
{ members: { $elemMatch: { userId: this.userId, isActive: true }}},
],
- }, { limit: 1 }), function(boardId, board) {
+ // 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(Integrations.find({ boardId }));
@@ -99,24 +101,47 @@ Meteor.publishRelations('board', function(boardId) {
//
// And in the meantime our code below works pretty well -- it's not even a
// hack!
+
+ // Gather queries and send in bulk
+ const cardComments = this.join(CardComments);
+ cardComments.selector = (_ids) => ({ cardId: _ids });
+ const attachments = this.join(Attachments);
+ attachments.selector = (_ids) => ({ cardId: _ids });
+ const checklists = this.join(Checklists);
+ checklists.selector = (_ids) => ({ cardId: _ids });
+ const checklistItems = this.join(ChecklistItems);
+ checklistItems.selector = (_ids) => ({ cardId: _ids });
+ const parentCards = this.join(Cards);
+ parentCards.selector = (_ids) => ({ parentId: _ids });
+ const boards = this.join(Boards);
+ const subCards = this.join(Cards);
+
this.cursor(Cards.find({ boardId }), function(cardId, card) {
if (card.type === 'cardType-linkedCard') {
const impCardId = card.linkedId;
- this.cursor(Cards.find({ _id: impCardId }));
- this.cursor(CardComments.find({ cardId: impCardId }));
- this.cursor(Attachments.find({ cardId: impCardId }));
- this.cursor(Checklists.find({ cardId: impCardId }));
- this.cursor(ChecklistItems.find({ cardId: impCardId }));
+ subCards.push(impCardId);
+ cardComments.push(impCardId);
+ attachments.push(impCardId);
+ checklists.push(impCardId);
+ checklistItems.push(impCardId);
} else if (card.type === 'cardType-linkedBoard') {
- this.cursor(Boards.find({ _id: card.linkedId}));
+ boards.push(card.linkedId);
}
- this.cursor(CardComments.find({ cardId }));
- this.cursor(Attachments.find({ cardId }));
- this.cursor(Checklists.find({ cardId }));
- this.cursor(ChecklistItems.find({ cardId }));
- this.cursor(Cards.find({ parentId: cardId }));
+ cardComments.push(cardId);
+ attachments.push(cardId);
+ checklists.push(cardId);
+ checklistItems.push(cardId);
+ parentCards.push(cardId);
});
+ // Send bulk queries for all found ids
+ subCards.send();
+ cardComments.send();
+ attachments.send();
+ checklists.send();
+ checklistItems.send();
+ boards.send();
+
if (board.members) {
// Board members. This publication also includes former board members that
// aren't members anymore but may have some activities attached to them in