Skip to content

Commit

Permalink
changing problematic definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelM3 committed Jun 28, 2023
1 parent 7f16995 commit aa79f86
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
40 changes: 20 additions & 20 deletions lib/models/entitiesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
'use strict';

const { info } = require('console');

var async = require('async'),
appContext = require('../appContext'),
config = require('../../config'),
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down
1 change: 0 additions & 1 deletion test/unit/entitiesStore_utest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit aa79f86

Please sign in to comment.