diff --git a/contrib/monitor/js/eddn.js b/contrib/monitor/js/eddn.js index 3407f0f..239cb90 100644 --- a/contrib/monitor/js/eddn.js +++ b/contrib/monitor/js/eddn.js @@ -30,22 +30,16 @@ var makeSlug = function(str) { } var makeName = function(str) { - var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)$/.exec(str); + var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)(\/live)?$/.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); + var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/(test|beta)$/.exec(str); if(match) { - return match[1].toUpperCase() + match[2] + " v" + match[3] + " [TEST]"; - } - - var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/beta$/.exec(str); - if(match) - { - return match[1].toUpperCase() + match[2] + " v" + match[3] + " [BETA]"; + return match[1].toUpperCase() + match[2] + " v" + match[3] + " [" + match[4].toUpperCase() + "]"; } return str; diff --git a/contrib/monitor/schemas.html b/contrib/monitor/schemas.html index 09eeb5a..78a40bb 100644 --- a/contrib/monitor/schemas.html +++ b/contrib/monitor/schemas.html @@ -121,22 +121,16 @@ return finishedslug.toLowerCase(); } var makeName = function(str) { - var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)$/.exec(str); + var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)(\/live)?$/.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); + var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/(test|beta)$/.exec(str); if(match) { - return match[1].toUpperCase() + match[2] + " v" + match[3] + " [TEST]"; - } - - var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/beta$/.exec(str); - if(match) - { - return match[1].toUpperCase() + match[2] + " v" + match[3] + " [BETA]"; + return match[1].toUpperCase() + match[2] + " v" + match[3] + " [" + match[4].toUpperCase() + "]"; } return str; diff --git a/contrib/nginx-eddn.conf b/contrib/nginx-eddn.conf index 236a0fb..9db4cbb 100644 --- a/contrib/nginx-eddn.conf +++ b/contrib/nginx-eddn.conf @@ -21,7 +21,7 @@ server { ssl_certificate /etc/letsencrypt/live/eddn.edcd.io/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/eddn.edcd.io/privkey.pem; - location ~ "^/schemas/(.*)/([\d]{1})(/(test|beta))?$" { + location ~ "^/schemas/(.*)/([\d]{1})(/(test|beta|live))?$" { add_header Content-Type application/json; alias /home/EDDN/schemas/$1-v$2.0.json; } diff --git a/src/eddn/Monitor.py b/src/eddn/Monitor.py index 39927ea..422ffe0 100644 --- a/src/eddn/Monitor.py +++ b/src/eddn/Monitor.py @@ -202,10 +202,16 @@ class Monitor(Thread): c.execute('INSERT IGNORE INTO `softwares` (`name`, `dateStats`) VALUES (%s, UTC_DATE())', (softwareID, )) db.commit() + # remove live endpoint from schema for the update + if schemaID.endswith('/live'): + upd_schema = schemaID[:-5] + else: + upd_schema = schemaID + # Update schemas count c = db.cursor() - c.execute('UPDATE `schemas` SET `hits` = `hits` + 1 WHERE `name` = %s AND `dateStats` = UTC_DATE()', (schemaID, )) - c.execute('INSERT IGNORE INTO `schemas` (`name`, `dateStats`) VALUES (%s, UTC_DATE())', (schemaID, )) + c.execute('UPDATE `schemas` SET `hits` = `hits` + 1 WHERE `name` = %s AND `dateStats` = UTC_DATE()', (upd_schema, )) + c.execute('INSERT IGNORE INTO `schemas` (`name`, `dateStats`) VALUES (%s, UTC_DATE())', (upd_schema, )) db.commit() db.close() diff --git a/src/eddn/conf/Settings.py b/src/eddn/conf/Settings.py index 2c9d84f..46c342d 100644 --- a/src/eddn/conf/Settings.py +++ b/src/eddn/conf/Settings.py @@ -46,22 +46,27 @@ class _Settings(object): GATEWAY_JSON_SCHEMAS = { "https://eddn.edcd.io/schemas/commodity/3" : "schemas/commodity-v3.0.json", + "https://eddn.edcd.io/schemas/commodity/3/live" : "schemas/commodity-v3.0.json", "https://eddn.edcd.io/schemas/commodity/3/test" : "schemas/commodity-v3.0.json", "https://eddn.edcd.io/schemas/commodity/3/beta" : "schemas/commodity-v3.0.json", "https://eddn.edcd.io/schemas/shipyard/2" : "schemas/shipyard-v2.0.json", + "https://eddn.edcd.io/schemas/shipyard/2/live" : "schemas/shipyard-v2.0.json", "https://eddn.edcd.io/schemas/shipyard/2/test" : "schemas/shipyard-v2.0.json", "https://eddn.edcd.io/schemas/shipyard/2/beta" : "schemas/shipyard-v2.0.json", "https://eddn.edcd.io/schemas/outfitting/2" : "schemas/outfitting-v2.0.json", + "https://eddn.edcd.io/schemas/outfitting/2/live" : "schemas/outfitting-v2.0.json", "https://eddn.edcd.io/schemas/outfitting/2/test" : "schemas/outfitting-v2.0.json", "https://eddn.edcd.io/schemas/outfitting/2/beta" : "schemas/outfitting-v2.0.json", "https://eddn.edcd.io/schemas/blackmarket/1" : "schemas/blackmarket-v1.0.json", + "https://eddn.edcd.io/schemas/blackmarket/1/live" : "schemas/blackmarket-v1.0.json", "https://eddn.edcd.io/schemas/blackmarket/1/test" : "schemas/blackmarket-v1.0.json", "https://eddn.edcd.io/schemas/blackmarket/1/beta" : "schemas/blackmarket-v1.0.json", "https://eddn.edcd.io/schemas/journal/1" : "schemas/journal-v1.0.json", + "https://eddn.edcd.io/schemas/journal/1/live" : "schemas/journal-v1.0.json", "https://eddn.edcd.io/schemas/journal/1/test" : "schemas/journal-v1.0.json", "https://eddn.edcd.io/schemas/journal/1/beta" : "schemas/journal-v1.0.json", } diff --git a/src/eddn/core/DuplicateMessages.py b/src/eddn/core/DuplicateMessages.py index b32844d..26687b9 100644 --- a/src/eddn/core/DuplicateMessages.py +++ b/src/eddn/core/DuplicateMessages.py @@ -36,9 +36,15 @@ class DuplicateMessages(Thread): if re.search('test', json['$schemaRef'], re.I): return False + # remove live endpoint from schema + if json['$schemaRef'].endswith('/live'): + schema_ref = json['$schemaRef'][:-5] + else: + schema_ref = json['$schemaRef'] + # Shallow copy, minus headers jsonTest = { - '$schemaRef': json['$schemaRef'], + '$schemaRef': schema_ref, 'message': dict(json['message']), }