diff --git a/db_server/dbserver.js b/db_server/dbserver.js index e38e7b6..37397c5 100644 --- a/db_server/dbserver.js +++ b/db_server/dbserver.js @@ -12,6 +12,7 @@ const mats = require('./mats.json'); const outs = require('./outs.json'); //genItems(); //generate base item collection +//genSystems(); //generate systems console.log("Updating Items!"); newUpdateItems(); @@ -60,6 +61,36 @@ function bpBuilder(){ writeToFile(bparr); } +function genSystems(){ + let esiurl = "https://esi.evetech.net/latest/industry/systems/?datasource=tranquility"; + request(esiurl, function(err, res, body) { + let esi = JSON.parse(body); + let sys = []; + for (let i = 0; i < systems.length; i++) { + let temp = { + "insertOne": { + "_id": systems[i].solarSystemID, + "name": systems[i].solarSystemName, + "index": getSystem(esi, systems[i].solarSystemID).cost_indices[5].cost_index + } + } + sys.push(temp); + } + mongo.connect(svurl, function(err, db) { + if (err) { + console.log(err); + } else { + db.collection('systems').bulkWrite(sys, { "ordered": true, "w": 1 }, function(err, result) { + if (err) throw err; + console.log(result.modifiedCount); + console.log("Cost Index UPDATED!"); + db.close(); + }); + } + }); + }); +} + function writeToFile(arr){ console.log("A escrever ficheiro..."); fs.writeFile("./new_bps.json",JSON.stringify(arr)); @@ -106,7 +137,7 @@ function getSystem(arr, id) { } function updateCostIndex() { - let esiurl = "https://esi.tech.ccp.is/latest/industry/systems/?datasource=tranquility"; + let esiurl = "https://esi.evetech.net/latest/industry/systems/?datasource=tranquility"; request(esiurl, function(err, res, body) { let esi = JSON.parse(body); let sys = []; @@ -287,4 +318,4 @@ function addDaily() { //need to re-write this } }); }); -} \ No newline at end of file +} diff --git a/routes/comp.js b/routes/comp.js index 2613ebb..de8d281 100644 --- a/routes/comp.js +++ b/routes/comp.js @@ -38,6 +38,7 @@ function getSimplePrice(data, id) { "sell": tempsell, "buy": tempbuy } + console.log(exp); return exp; } } @@ -1004,4 +1005,4 @@ router.get('/:id',function(req, res, next){ }); }); -module.exports = router; \ No newline at end of file +module.exports = router; diff --git a/routes/hyb.js b/routes/hyb.js index 6ef2a7e..5147f0f 100644 --- a/routes/hyb.js +++ b/routes/hyb.js @@ -660,4 +660,4 @@ router.get('/:id',function(req, res, next){ }); }); -module.exports = router; \ No newline at end of file +module.exports = router; diff --git a/views/comp.hbs b/views/comp.hbs index 266a07f..51b3345 100644 --- a/views/comp.hbs +++ b/views/comp.hbs @@ -149,7 +149,7 @@
- Complex Chain Reactions + Complex Chain Reactions (broken)