This commit is contained in:
José Valdiviesso 2019-01-09 15:25:40 +00:00
parent 6dcbb36c9c
commit eebea3a337
4 changed files with 37 additions and 5 deletions

View File

@ -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
}
});
});
}
}

View File

@ -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;
module.exports = router;

View File

@ -660,4 +660,4 @@ router.get('/:id',function(req, res, next){
});
});
module.exports = router;
module.exports = router;

View File

@ -149,7 +149,7 @@
<div class="card w-100 mt-3">
<div class="card-header bg-info text-white text-center w-100">
Complex Chain Reactions
Complex Chain Reactions (broken)
</div>
<table width="100%" id="chtab" class="table table-bordered text-center">
<thead>