csantanapr commented on a change in pull request #82: Applying filter on all db 
changes since 0 takes too long
URL: 
https://github.com/apache/incubator-openwhisk-package-alarms/pull/82#discussion_r131733024
 
 

 ##########
 File path: provider/lib/utils.js
 ##########
 @@ -216,25 +210,26 @@ module.exports = function(
     this.initAllTriggers = function() {
         var method = 'initAllTriggers';
 
-        logger.info(method, 'resetting system from last state');
+        //follow the trigger DB
+        utils.setupFollow('now');
 
-        triggerDB.changes({ since: 0, include_docs: true, filter: ddname + '/' 
+ filter, worker: utils.worker }, (err, changes) => {
+        logger.info(method, 'resetting system from last state');
+        triggerDB.view(viewDDName, triggersByWorker, {reduce: false, 
include_docs: true}, function(err, body) {
             if (!err) {
-                changes.results.forEach(function (change) {
-                    var triggerIdentifier = change.id;
-                    var doc = change.doc;
+                body.rows.forEach(function (trigger) {
+                    var triggerIdentifier = trigger.id;
+                    var doc = trigger.doc;
 
-                    if (!doc.status || doc.status.active === true) {
+                    if (trigger.key === utils.worker && (!doc.status || 
doc.status.active === true) && !(triggerIdentifier in utils.triggers)) {
 
 Review comment:
   by using key in the view, no need to check the worker
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to