Преглед изворни кода

Speed improvement: Delete presences older than one week, and add index to presences serverId.

Thanks to xet7 !

Related #3345
Lauri Ojansivu пре 4 година
родитељ
комит
9db3c93116
2 измењених фајлова са 14 додато и 2 уклоњено
  1. 12 0
      models/presences.js
  2. 2 2
      server/notifications/outgoing.js

+ 12 - 0
models/presences.js

@@ -0,0 +1,12 @@
+if (Meteor.isServer) {
+  Meteor.startup(() => {
+    // Date of 7 days ago
+    let lastWeek = new Date();
+    lastWeek.setDate(lastWeek.getDate() - 7);
+
+    presences.remove({ ttl: { $lte: lastWeek } });
+
+    // Create index for serverId that is queried often
+    presences._collection._ensureIndex({ serverId: -1 });
+  });
+}

+ 2 - 2
server/notifications/outgoing.js

@@ -63,7 +63,7 @@ if (Meteor.isServer) {
     'swimlaneId',
     'customField',
     'customFieldValue',
-    'attachmentId'
+    'attachmentId',
   ];
   const responseFunc = data => {
     const paramCommentId = data.commentId;
@@ -125,7 +125,7 @@ if (Meteor.isServer) {
           'oldSwimlane',
           'label',
           'attachment',
-          'attachmentId'
+          'attachmentId',
         ].forEach(key => {
           if (quoteParams[key]) quoteParams[key] = `"${params[key]}"`;
         });