lib/jobs/wait-sel-events-job.js
function _verifyFiltering(filters, counts, data) {
        var reading = data.data.alert.reading;
        if (_.isEmpty(reading)) {
            return false;
        }
        var filter = filters[0];
        var count = counts[0];
        var matched = true;
        _.map(filter, function(value, key){
            if (data.data.alert.reading[key] !== value) {
                matched = false;
            }
        });
        if (matched) {
            count = count - 1;
            if (count === 0){
                filters.shift();
                counts.shift();
            } else {
                counts[0] = count;
            }
        }
        if (_.isEmpty(filters)){
            return true;
        }
        return false;
    }
function _verifyFiltering(filters, counts, data) {
        var reading = data.data.alert.reading;
        if (_.isEmpty(reading)) {
            return false;
        }
        var filter = filters[0];
        var count = counts[0];
        var matched = true;
        _.map(filter, function(value, key){
            if (data.data.alert.reading[key] !== value) {
                matched = false;
            }
        });
        if (matched) {
            count = count - 1;
            if (count === 0){
                filters.shift();
                counts.shift();
            } else {
                counts[0] = count;
            }
        }
        if (_.isEmpty(filters)){
            return true;
        }
        return false;
    }
function _verifyFiltering ( filters , counts , data ) { var reading = data . data . alert . reading ; if ( _ . isEmpty ( reading ) ) { return false ; } var filter = filters [ 0 ] ; var count = counts [ 0 ] ; var matched = true ; _ . map ( filter , function ( value , key ) { if ( data . data . alert . reading [ key ] !== value ) { matched = false ; } } ) ; if ( matched ) { count = count - 1 ; if ( count === 0 ) { filters . shift ( ) ; counts . shift ( ) ; } else { counts [ 0 ] = count ; } } if ( _ . isEmpty ( filters ) ) { return true ; } return false ; }
Validate events data against filtering conditions.
Alert filters will be validated by indexing sequence.
Each alert filter can includes an attribute "count" to indicate how many times this event
should happen continuously
@param {Array} filters: an array of alert filters in sequence
@param {Array} counts: an array of alert filters counting in sequence
@param {Object} data: AMQP data received
@return {Boolean}: true if all filtering conditions are met, false otherwise.
Validate events data against filtering conditions . Alert filters will be validated by indexing sequence . Each alert filter can includes an attribute count to indicate how many times this event should happen continuously