From aa79f8612ce24b6577226b69ae7d464ddd797a51 Mon Sep 17 00:00:00 2001 From: RafaelM3 Date: Wed, 28 Jun 2023 17:48:57 +0200 Subject: [PATCH] changing problematic definitions --- lib/models/entitiesStore.js | 40 ++++++++++++++++---------------- package.json | 2 +- test/unit/entitiesStore_utest.js | 1 - 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/lib/models/entitiesStore.js b/lib/models/entitiesStore.js index 10ced9ba..29e85c2d 100644 --- a/lib/models/entitiesStore.js +++ b/lib/models/entitiesStore.js @@ -22,6 +22,8 @@ */ 'use strict'; +const { info } = require('console'); + var async = require('async'), appContext = require('../appContext'), config = require('../../config'), @@ -80,28 +82,9 @@ function createConnection(service, subservice) { return new ngsi.Connection(config.orion.URL, options); } -function findSilentEntitiesByAPI(service, subservice, ruleData, func, callback) { - var limit = limit || 20; - var offset = offset || 0; - +function findSilentEntitiesByAPIWithPagination(connection, filter, func, callback) { var context = { op: 'checkNoSignal.findSilentEntitiesByAPI', comp: constants.COMPONENT_NAME }; - var connection = createConnection(service, subservice); - var filter = createFilter(ruleData, service, subservice, limit, offset); - - logger.info( - context, - 'find silent entities by API ngsi using options %j and filter %j and rule %j', - connection, - filter, - ruleData - ); - - // Call the pagination function - findSilentEntitiesByAPIWithPagination(connection, filter, func, callback); -} - -function findSilentEntitiesByAPIWithPagination(connection, filter, func, callback) { // https://ficodes.github.io/ngsijs/stable/NGSI.Connection.html#.%22v2.listEntities%22__anchor connection.v2.listEntities(filter).then( (response) => { @@ -134,6 +117,23 @@ function findSilentEntitiesByAPIWithPagination(connection, filter, func, callbac ); } +function findSilentEntitiesByAPI(service, subservice, ruleData, func, callback) { + var limit = limit || 20; + var offset = offset || 0; + var connection = createConnection(service, subservice); + var filter = createFilter(ruleData, service, subservice, limit, offset); + + logger.info( + 'find silent entities by API ngsi using options %j and filter %j and rule %j', + connection, + filter, + ruleData + ); + + // Call the pagination function + findSilentEntitiesByAPIWithPagination(connection, filter, func, callback); +} + function findSilentEntitiesByMongo(service, subservice, ruleData, func, callback) { var db, context = { op: 'checkNoSignal.findSilentEntitiesByMongo', comp: constants.COMPONENT_NAME }, diff --git a/package.json b/package.json index a3a62456..155be63f 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "scripts": { "clean": "rm -rf package-lock.json && rm -rf node_modules && rm -rf coverage", "healthcheck": "node ./bin/healthcheck", - "test": "mocha --recursive 'test/unit/entitiesStore_utest.js' --reporter spec --timeout 5000 --ui bdd --exit --color true", + "test": "mocha --recursive 'test/**/*.js' --reporter spec --timeout 5000 --ui bdd --exit --color true", "test:watch": "npm run test -- -w ./lib", "lint": "jshint lib/ --config .jshintrc && jshint bin/ --config .jshintrc && jshint test/ --config test/.jshintrc", "lint:md": "remark -f '*.md' 'docs/*.md'", diff --git a/test/unit/entitiesStore_utest.js b/test/unit/entitiesStore_utest.js index d5714566..214fb492 100644 --- a/test/unit/entitiesStore_utest.js +++ b/test/unit/entitiesStore_utest.js @@ -32,7 +32,6 @@ var chai = require('chai'); var sinon = require('sinon'); var sinonChai = require('sinon-chai'); var config = require('../../config.js'); -var ngsi = require('ngsijs'); chai.Should(); chai.use(sinonChai);