Explorar o código

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

Martin Filser %!s(int64=2) %!d(string=hai) anos
pai
achega
2a2ed1eb2c

+ 10 - 6
server/publications/boards.js

@@ -65,7 +65,7 @@ Meteor.publishRelations('boards', function() {
         )
       );
       this.cursor(
-        Cards.find(
+        ReactiveCache.getCards(
           { boardId, archived: false },
           { fields: {
             _id: 1,
@@ -73,7 +73,8 @@ Meteor.publishRelations('boards', function() {
             listId: 1,
             archived: 1,
             sort: 1
-          }}
+          }},
+          true,
         )
       );
     }
@@ -271,10 +272,13 @@ Meteor.publishRelations('board', function(boardId, isArchived) {
       linkedBoardCards.selector = _ids => ({ boardId: _ids });
 
       this.cursor(
-        Cards.find({
-          boardId: { $in: [boardId, board.subtasksDefaultBoardId] },
-          archived: isArchived,
-        }),
+        ReactiveCache.getCards({
+            boardId: { $in: [boardId, board.subtasksDefaultBoardId] },
+            archived: isArchived,
+          },
+          {},
+          true,
+        ),
         function(cardId, card) {
           if (card.type === 'cardType-linkedCard') {
             const impCardId = card.linkedId;

+ 11 - 3
server/publications/cards.js

@@ -56,7 +56,11 @@ import Team from "../../models/team";
 
 Meteor.publish('card', cardId => {
   check(cardId, String);
-  const ret = Cards.find({ _id: cardId });
+  const ret = ReactiveCache.getCards(
+    { _id: cardId },
+    {},
+    true,
+  );
   return ret;
 });
 
@@ -66,7 +70,11 @@ Meteor.publish('card', cardId => {
 Meteor.publishRelations('popupCardData', function(cardId) {
   check(cardId, String);
   this.cursor(
-    Cards.find({_id: cardId}),
+    ReactiveCache.getCards(
+      { _id: cardId },
+      {},
+      true,
+    ),
     function(cardId, card) {
       this.cursor(ReactiveCache.getBoards({_id: card.boardId}, {}, true));
       this.cursor(Lists.find({boardId: card.boardId}));
@@ -680,7 +688,7 @@ function findCards(sessionId, query) {
   // eslint-disable-next-line no-console
   // console.log('projection:', query.projection);
 
-  const cards = Cards.find(query.selector, query.projection);
+  const cards = ReactiveCache.getCards(query.selector, query.projection, true);
   // eslint-disable-next-line no-console
   // console.log('count:', cards.count());
 

+ 10 - 6
server/publications/notifications.js

@@ -22,13 +22,17 @@ Meteor.publish('notificationAttachments', function() {
 
 // gets all cards associated with activities associated with the current user
 Meteor.publish('notificationCards', function() {
-  const ret = Cards.find({
-    _id: {
-      $in: activities()
-        .map(v => v.cardId)
-        .filter(v => !!v),
+  const ret = ReactiveCache.getCards(
+    {
+      _id: {
+        $in: activities()
+          .map(v => v.cardId)
+          .filter(v => !!v),
+      },
     },
-  });
+    {},
+    true,
+  );
   return ret;
 });