From e6d878c603144e35b809504d17b5cbfd218eb2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Kopp?= Date: Tue, 30 Nov 2021 16:01:52 +0100 Subject: [PATCH] move default parameters from db/ip to dataController --- app/controllers/dataController.js | 11 +++++++++-- app/db/ip.js | 12 ++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/dataController.js b/app/controllers/dataController.js index a906346..c09c3b7 100644 --- a/app/controllers/dataController.js +++ b/app/controllers/dataController.js @@ -76,10 +76,17 @@ exports.getUsers = (userId) => { }); }; -exports.getTopIPs = (userId) => { +exports.getTopIPs = ( userId, + filter={}, + period_start = (new Date().getFullYear())+'-01-01 00:00:00', + period_end = (new Date().getFullYear() + 1)+'-01-01 00:00:00', + measure='units', + level='month', + min_exist = 0 + ) => { logger.trace(); return new promise((resolve, reject) => { - db.ip.getTop() + db.ip.getTop(filter,period_start,period_end,measure,level,min_exist) .then(data => { db.user.logAction(userId, 'listIPs'); resolve(data); diff --git a/app/db/ip.js b/app/db/ip.js index db60fe2..f23d475 100644 --- a/app/db/ip.js +++ b/app/db/ip.js @@ -117,12 +117,12 @@ function createFilter(filter){ -exports.getTop = (filter={}, - period_start = (new Date().getFullYear())+'-01-01 00:00:00', - period_end = (new Date().getFullYear() + 1)+'-01-01 00:00:00', - measure='units', - level='month', - min_exist = 0 +exports.getTop = (filter, + period_start, + period_end, + measure, + level, + min_exist ) => { logger.trace(); logger.warn('db.ip.getTop() uses only default settings !!!');