diff --git a/packages/unleash-api/lib/db/client-instances.js b/packages/unleash-api/lib/db/client-instances.js index b69805390b..5e050a8f37 100644 --- a/packages/unleash-api/lib/db/client-instances.js +++ b/packages/unleash-api/lib/db/client-instances.js @@ -9,9 +9,9 @@ module.exports = function (db) { return db(TABLE) .where('app_name', details.appName) .where('instance_id', details.instanceId) - .where('client_ip', details.clientIp) .update({ last_seen: 'now()', + client_ip: details.clientIp, }); } @@ -24,11 +24,11 @@ module.exports = function (db) { } function insert (details) { + console.log(details); return db(TABLE) .count('*') .where('app_name', details.appName) .where('instance_id', details.instanceId) - .where('client_ip', details.clientIp) .map(row => ({ count: row.count })) .then(rows => { if (rows[0].count > 0) { diff --git a/packages/unleash-api/lib/routes/metrics.js b/packages/unleash-api/lib/routes/metrics.js index 35640fa7b9..294ca2af8a 100644 --- a/packages/unleash-api/lib/routes/metrics.js +++ b/packages/unleash-api/lib/routes/metrics.js @@ -42,11 +42,12 @@ module.exports = function (app, config) { app.post('/client/register', (req, res) => { const data = req.body; + const clientIp = req.ip; clientStrategiesDb.insert(data.appName, data.strategies) .then(() => clientInstancesDb.insert({ appName: data.appName, instanceId: data.instanceId, - clientIp: req.ip, + clientIp, })) .then(() => console.log('new client registerd')) .catch((error) => logger.error('Error registering client', error));