Browse Source

changes

pull/1/head
José Valdiviesso 3 years ago
parent
commit
eebea3a337
  1. 35
      db_server/dbserver.js
  2. 3
      routes/comp.js
  3. 2
      routes/hyb.js
  4. 2
      views/comp.hbs

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

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

2
routes/hyb.js

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

2
views/comp.hbs

@ -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>

Loading…
Cancel
Save