Skip to content

Commit

Permalink
Update old schemas to new schemas in main monitor front
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthorNet authored Aug 10, 2017
1 parent 17bae4b commit fa753ab
Showing 1 changed file with 49 additions and 22 deletions.
71 changes: 49 additions & 22 deletions contrib/monitor/js/eddn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ var updateInterval = 60000,
relayBottlePort = 9090,

gateways = [
'eddn.edcd.io',
//'eddn-gateway.elite-markets.net'
], // Must find a way to bind them to monitor
'eddn.edcd.io'
], //TODO: Must find a way to bind them to monitor

relays = [
'eddn.edcd.io',
//'eddn-relay.elite-markets.net'
]; // Must find a way to bind them to monitor
'eddn.edcd.io'
]; //TODO: Must find a way to bind them to monitor

var stats = {
'gateways' : {},
Expand All @@ -32,21 +30,19 @@ var makeSlug = function(str) {
}

var makeName = function(str) {
var match = /^http:\/\/schemas.elite-markets.net\/eddn\/(\w)(\w*)\/(\d+)$/.exec(str);

if(match)
{
return match[1].toUpperCase() + match[2] + " v" + match[3];
}

var match = /^http:\/\/schemas.elite-markets.net\/eddn\/(\w)(\w*)\/(\d+)\/test$/.exec(str);

if(match)
{
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [TEST]";
}

return str;
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)$/.exec(str);
if(match)
{
return match[1].toUpperCase() + match[2] + " v" + match[3];
}

var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/test$/.exec(str);
if(match)
{
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [TEST]";
}

return str;
}

secondsToDurationString = function(seconds) {
Expand Down Expand Up @@ -376,7 +372,17 @@ var doUpdateSchemas = function()
$.ajax({
dataType: "json",
url: monitorEndPoint + 'getTotalSchemas/',
success: function(schemasTotal){
success: function(schemasTotalTmp){
// Convert old schemas and sum them to new schemas
schemasTotal = {};
$.each(schemasTotalTmp, function(schema, hits){
schema = schema.replace('http://schemas.elite-markets.net/eddn/', 'https://eddn.edcd.io/schemas/');
hits = parseInt(hits);

if(schemasTotal[schema]){ schemasTotal[schema] += hits; }
else{ schemasTotal[schema] = hits; }
});

var chart = $('#schemas .chart').highcharts(),
series = chart.get('schemas');

Expand All @@ -388,6 +394,27 @@ var doUpdateSchemas = function()
schemas[yesterday] = [];
if(schemas[today] == undefined)
schemas[today] = [];

// Convert old schemas and sum them to new schemas
schemasYesterdayTmp = {};
$.each(schemas[yesterday], function(schema, hits){
schema = schema.replace('http://schemas.elite-markets.net/eddn/', 'https://eddn.edcd.io/schemas/');
hits = parseInt(hits);

if(schemasYesterdayTmp[schema]){ schemasYesterdayTmp[schema] += hits; }
else{ schemasYesterdayTmp[schema] = hits; }
});
schemas[yesterday] = schemasYesterdayTmp;

schemasTodayTmp = {};
$.each(schemas[today], function(schema, hits){
schema = schema.replace('http://schemas.elite-markets.net/eddn/', 'https://eddn.edcd.io/schemas/');
hits = parseInt(hits);

if(schemasTodayTmp[schema]){ schemasYesterdayTmp[schema] += hits; }
else{ schemasTodayTmp[schema] = hits; }
});
schemas[today] = schemasTodayTmp;

var slug = makeSlug(schema);
var name = makeName(schema);
Expand Down

0 comments on commit fa753ab

Please sign in to comment.