From 3c49e2d0edec19eff4f87b0fcc127f924af193fc Mon Sep 17 00:00:00 2001 From: Justin Reynolds Date: Thu, 28 Feb 2019 11:44:29 -0600 Subject: [PATCH 1/6] Performance Enhancements --- .meteor/packages | 1 + .meteor/versions | 1 + models/attachments.js | 4 +++ models/checklistItems.js | 1 + models/customFields.js | 6 ++--- models/integrations.js | 4 +++ server/publications/boards.js | 49 ++++++++++++++++++++++++++--------- 7 files changed, 51 insertions(+), 15 deletions(-) diff --git a/.meteor/packages b/.meteor/packages index 274a8d0db..964c070ff 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -91,3 +91,4 @@ wekan:accounts-cas wekan-scrollbar mquandalle:perfect-scrollbar mdg:meteor-apm-agent +meteorhacks:unblock diff --git a/.meteor/versions b/.meteor/versions index e91115a24..71e2efac3 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -94,6 +94,7 @@ meteorhacks:collection-utils@1.2.0 meteorhacks:meteorx@1.4.1 meteorhacks:picker@1.0.3 meteorhacks:subs-manager@1.6.4 +meteorhacks:unblock@1.1.0 meteorspark:util@0.2.0 minifier-css@1.2.16 minifier-js@2.2.2 diff --git a/models/attachments.js b/models/attachments.js index 3da067dec..f870861ba 100644 --- a/models/attachments.js +++ b/models/attachments.js @@ -27,6 +27,10 @@ Attachments = new FS.Collection('attachments', { if (Meteor.isServer) { + Meteor.startup(() => { + Attachments.files._ensureIndex({ cardId: 1 }); + }); + Attachments.allow({ insert(userId, doc) { return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); diff --git a/models/checklistItems.js b/models/checklistItems.js index 35b18ed7f..30e57aec7 100644 --- a/models/checklistItems.js +++ b/models/checklistItems.js @@ -189,6 +189,7 @@ function publishChekListUncompleted(userId, doc){ if (Meteor.isServer) { Meteor.startup(() => { ChecklistItems._collection._ensureIndex({ checklistId: 1 }); + ChecklistItems._collection._ensureIndex({ cardId: 1 }); }); ChecklistItems.after.update((userId, doc, fieldNames) => { diff --git a/models/customFields.js b/models/customFields.js index 3e8aa250d..b7ad54672 100644 --- a/models/customFields.js +++ b/models/customFields.js @@ -98,9 +98,9 @@ function customFieldCreation(userId, doc){ } if (Meteor.isServer) { - /*Meteor.startup(() => { - CustomFields._collection._ensureIndex({ boardId: 1}); - });*/ + Meteor.startup(() => { + CustomFields._collection._ensureIndex({ boardId: 1 }); + }); CustomFields.after.insert((userId, doc) => { customFieldCreation(userId, doc); diff --git a/models/integrations.js b/models/integrations.js index 1c473b57e..65a7af637 100644 --- a/models/integrations.js +++ b/models/integrations.js @@ -88,6 +88,10 @@ Integrations.allow({ //INTEGRATIONS REST API if (Meteor.isServer) { + Meteor.startup(() => { + Integrations._collection._ensureIndex({ boardId: 1 }); + }); + /** * @operation get_all_integrations * @summary Get all integrations in board diff --git a/server/publications/boards.js b/server/publications/boards.js index 71c53612d..18c44d2b1 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 From 49229e1723de14cdc66dc6480624bba426d35e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Manelli?= Date: Thu, 28 Feb 2019 20:43:45 +0100 Subject: [PATCH 2/6] Fix filter in swimlanes view --- models/swimlanes.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/models/swimlanes.js b/models/swimlanes.js index 1b18ba5d8..9da4afb5f 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -133,14 +133,14 @@ Swimlanes.helpers({ }, lists() { - return Lists.find(Filter.mongoSelector({ + return Lists.find({ boardId: this.boardId, swimlaneId: {$in: [this._id, '']}, archived: false, - }), { sort: ['sort'] }); + }, { sort: ['sort'] }); }, - allLists() { + myLists() { return Lists.find({ swimlaneId: this._id }); }, @@ -189,7 +189,7 @@ Swimlanes.mutations({ archive() { if (this.isTemplateSwimlane()) { - this.lists().forEach((list) => { + this.myLists().forEach((list) => { return list.archive(); }); } @@ -198,7 +198,7 @@ Swimlanes.mutations({ restore() { if (this.isTemplateSwimlane()) { - this.allLists().forEach((list) => { + this.myLists().forEach((list) => { return list.restore(); }); } From 3edff32bde9eda3c0ea8bf3960aa8eef1a3c5524 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 28 Feb 2019 22:37:28 +0200 Subject: [PATCH 3/6] [Performance improvements](https://github.com/wekan/wekan/pull/2214), thanks to justinr1234: - New indexes for queries that were missing an index; - Bulk querying documents to reduce the number of mongo queries when loading a board; - Ensure oplog is being used to query the database by providing a `sort` key when `limit` is used querying the `boards` collection. --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d50c3832..96ae292b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Upcoming Wekan release + +This release adds the following [performance improvements](https://github.com/wekan/wekan/pull/2214), thanks to justinr1234: + +- New indexes for queries that were missing an index; +- Bulk querying documents to reduce the number of mongo queries when loading a board; +- Ensure oplog is being used to query the database by providing a `sort` key when `limit` is used querying the `boards` collection. + +Thanks to above GitHub users for their contributions. + # v2.31 2019-02-28 Wekan release This release fixes the following bugs related to [Template features](https://github.com/wekan/wekan/issues/2209), thanks to GitHub user andresmanelli: From 24e47195e556b6f36b36f8e1a8f09737eaebb784 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 28 Feb 2019 22:45:37 +0200 Subject: [PATCH 4/6] - [Fix](https://github.com/wekan/wekan/commit/49229e1723de14cdc66dc6480624bba426d35e36) [Filtering in swimlane view is broken since v2.29](https://github.com/wekan/wekan/issues/2213). Thanks to andresmanelli ! Related #2209 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96ae292b4..fdcabc16d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ This release adds the following [performance improvements](https://github.com/we - Bulk querying documents to reduce the number of mongo queries when loading a board; - Ensure oplog is being used to query the database by providing a `sort` key when `limit` is used querying the `boards` collection. +and [fixes](https://github.com/wekan/wekan/commit/49229e1723de14cdc66dc6480624bba426d35e36) the following bugs +related to [Template features](https://github.com/wekan/wekan/issues/2209), thanks to andresmanelli: + +- [Filtering in swimlane view is broken since v2.29](https://github.com/wekan/wekan/issues/2213). + Thanks to above GitHub users for their contributions. # v2.31 2019-02-28 Wekan release From 8e36a2bc838fb15f88bbbadcfad9528f2a41a3c6 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 28 Feb 2019 22:57:40 +0200 Subject: [PATCH 5/6] [Fix filtering in swimlane view](https://github.com/wekan/wekan/commit/49229e1723de14cdc66dc6480624bba426d35e36) that was [broken since v2.29](https://github.com/wekan/wekan/issues/2213). Thanks to andresmanelli ! Closes #2213, Related #2209 --- CHANGELOG.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdcabc16d..b23321f26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Upcoming Wekan release +# v2.32 2019-02-28 Wekan release This release adds the following [performance improvements](https://github.com/wekan/wekan/pull/2214), thanks to justinr1234: @@ -6,10 +6,9 @@ This release adds the following [performance improvements](https://github.com/we - Bulk querying documents to reduce the number of mongo queries when loading a board; - Ensure oplog is being used to query the database by providing a `sort` key when `limit` is used querying the `boards` collection. -and [fixes](https://github.com/wekan/wekan/commit/49229e1723de14cdc66dc6480624bba426d35e36) the following bugs -related to [Template features](https://github.com/wekan/wekan/issues/2209), thanks to andresmanelli: +and fixes the following bugs related to [Template features](https://github.com/wekan/wekan/issues/2209), thanks to andresmanelli: -- [Filtering in swimlane view is broken since v2.29](https://github.com/wekan/wekan/issues/2213). +- [Fix filtering in swimlane view](https://github.com/wekan/wekan/commit/49229e1723de14cdc66dc6480624bba426d35e36) that was [broken since v2.29](https://github.com/wekan/wekan/issues/2213). Thanks to above GitHub users for their contributions. From 49882a05d1d1e5cacc950daa282bd6f6ea0d402f Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 28 Feb 2019 23:01:56 +0200 Subject: [PATCH 6/6] v2.32 --- Stackerfile.yml | 2 +- package.json | 2 +- sandstorm-pkgdef.capnp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Stackerfile.yml b/Stackerfile.yml index 8ee99ee84..beb27125e 100644 --- a/Stackerfile.yml +++ b/Stackerfile.yml @@ -1,5 +1,5 @@ appId: wekan-public/apps/77b94f60-dec9-0136-304e-16ff53095928 -appVersion: "v2.31.0" +appVersion: "v2.32.0" files: userUploads: - README.md diff --git a/package.json b/package.json index 81916a54c..c463e40c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wekan", - "version": "v2.31.0", + "version": "v2.32.0", "description": "Open-Source kanban", "private": true, "scripts": { diff --git a/sandstorm-pkgdef.capnp b/sandstorm-pkgdef.capnp index e1ea4b81e..93b08ec8d 100644 --- a/sandstorm-pkgdef.capnp +++ b/sandstorm-pkgdef.capnp @@ -22,10 +22,10 @@ const pkgdef :Spk.PackageDefinition = ( appTitle = (defaultText = "Wekan"), # The name of the app as it is displayed to the user. - appVersion = 233, + appVersion = 234, # Increment this for every release. - appMarketingVersion = (defaultText = "2.31.0~2019-02-28"), + appMarketingVersion = (defaultText = "2.32.0~2019-02-28"), # Human-readable presentation of the app version. minUpgradableAppVersion = 0,