Bläddra i källkod

Move every Lists.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory server/)

Martin Filser 2 år sedan
förälder
incheckning
76bd3bfe1d
3 ändrade filer med 24 tillägg och 17 borttagningar
  1. 12 9
      server/publications/boards.js
  2. 2 2
      server/publications/cards.js
  3. 10 6
      server/publications/notifications.js

+ 12 - 9
server/publications/boards.js

@@ -53,15 +53,18 @@ Meteor.publishRelations('boards', function() {
   ),
   ),
     function(boardId, board) {
     function(boardId, board) {
       this.cursor(
       this.cursor(
-        Lists.find(
+        ReactiveCache.getLists(
           { boardId, archived: false },
           { boardId, archived: false },
-          { fields: {
-            _id: 1,
-            title: 1,
-            boardId: 1,
-            archived: 1,
-            sort: 1
-          }}
+          { fields:
+            {
+              _id: 1,
+              title: 1,
+              boardId: 1,
+              archived: 1,
+              sort: 1
+            }
+          },
+          true,
         )
         )
       );
       );
       this.cursor(
       this.cursor(
@@ -217,7 +220,7 @@ Meteor.publishRelations('board', function(boardId, isArchived) {
       true,
       true,
     ),
     ),
     function(boardId, board) {
     function(boardId, board) {
-      this.cursor(Lists.find({ boardId, archived: isArchived }));
+      this.cursor(ReactiveCache.getLists({ boardId, archived: isArchived }, {}, true));
       this.cursor(Swimlanes.find({ boardId, archived: isArchived }));
       this.cursor(Swimlanes.find({ boardId, archived: isArchived }));
       this.cursor(Integrations.find({ boardId }));
       this.cursor(Integrations.find({ boardId }));
       this.cursor(CardCommentReactions.find({ boardId }));
       this.cursor(CardCommentReactions.find({ boardId }));

+ 2 - 2
server/publications/cards.js

@@ -77,7 +77,7 @@ Meteor.publishRelations('popupCardData', function(cardId) {
     ),
     ),
     function(cardId, card) {
     function(cardId, card) {
       this.cursor(ReactiveCache.getBoards({_id: card.boardId}, {}, true));
       this.cursor(ReactiveCache.getBoards({_id: card.boardId}, {}, true));
-      this.cursor(Lists.find({boardId: card.boardId}));
+      this.cursor(ReactiveCache.getLists({boardId: card.boardId}, {}, true));
     },
     },
   );
   );
   const ret = this.ready()
   const ret = this.ready()
@@ -787,7 +787,7 @@ function findCards(sessionId, query) {
         { _id: { $in: swimlanes } },
         { _id: { $in: swimlanes } },
         { fields: { ...fields, color: 1 } },
         { fields: { ...fields, color: 1 } },
       ),
       ),
-      Lists.find({ _id: { $in: lists } }, { fields }),
+      ReactiveCache.getLists({ _id: { $in: lists } }, { fields }, true),
       CustomFields.find({ _id: { $in: customFieldIds } }),
       CustomFields.find({ _id: { $in: customFieldIds } }),
       Users.find({ _id: { $in: users } }, { fields: Users.safeFields }),
       Users.find({ _id: { $in: users } }, { fields: Users.safeFields }),
       Checklists.find({ cardId: { $in: cards.map(c => c._id) } }),
       Checklists.find({ cardId: { $in: cards.map(c => c._id) } }),

+ 10 - 6
server/publications/notifications.js

@@ -74,13 +74,17 @@ Meteor.publish('notificationComments', function() {
 
 
 // gets all lists associated with activities associated with the current user
 // gets all lists associated with activities associated with the current user
 Meteor.publish('notificationLists', function() {
 Meteor.publish('notificationLists', function() {
-  const ret = Lists.find({
-    _id: {
-      $in: activities()
-        .map(v => v.listId)
-        .filter(v => !!v),
+  const ret = ReactiveCache.getLists(
+    {
+      _id: {
+        $in: activities()
+          .map(v => v.listId)
+          .filter(v => !!v),
+      },
     },
     },
-  });
+    {},
+    true,
+  );
   return ret;
   return ret;
 });
 });