fixing neubaukompass && updating dependencies

This commit is contained in:
Christian Kellner
2019-10-24 21:25:19 +02:00
parent 8e225f761c
commit 9106144d9c
8 changed files with 341 additions and 529 deletions

View File

@@ -1,36 +1,35 @@
const config = require('../../conf/config.json');
let stats = {
lastScrape: {},
foundScrapes: {}
lastScrape: {},
foundScrapes: {}
};
if (config.enableStats) {
const http = require('http');
http
.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(
JSON.stringify({
config,
stats
})
);
const http = require('http');
http
.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(
JSON.stringify({
config,
stats
})
.listen(config.statsPort, '127.0.0.1');
);
})
.listen(config.statsPort, '127.0.0.1');
}
const datetime = date => {
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()} ${date.getHours()}:${date.getMinutes()}`;
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()} ${date.getHours()}:${date.getMinutes()}`;
};
exports.setLastScrape = (serviceName, numberOfNewListsings) => {
const d = new Date();
const dt = datetime(d);
stats.lastScrape[serviceName] = d.toString();
const d = new Date();
const dt = datetime(d);
stats.lastScrape[serviceName] = d.toString();
if (numberOfNewListsings > 0) {
stats.foundScrapes[dt] = stats.foundScrapes[dt] || {};
stats.foundScrapes[dt][serviceName] = numberOfNewListsings;
}
if (numberOfNewListsings > 0) {
stats.foundScrapes[dt] = stats.foundScrapes[dt] || {};
stats.foundScrapes[dt][serviceName] = numberOfNewListsings;
}
};