mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Moved gauge creation, 0 items don't fail requests
This commit is contained in:
1 parent
595b4e5ac9
commit
0fe5633926
1 file changed
+8
-5
@@ -258,7 +258,7 @@ db.items.addItem = function(object) {
|
|||||||
if(this[object.name] && Number(this[object.name]) != NaN){
|
if(this[object.name] && Number(this[object.name]) != NaN){
|
||||||
this[object.name] = Number(this[object.name]) + Number(object.count);
|
this[object.name] = Number(this[object.name]) + Number(object.count);
|
||||||
} else {
|
} else {
|
||||||
this[object.name] = object.count;
|
this[object.name] = Number(object.count);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -535,9 +535,12 @@ app.post("/api/place", authenticate.middleware, function(req, res) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const routes_api_remove = require("./routes/api/remove.js")
|
const routes_api_remove = require("./routes/api/remove.js")
|
||||||
const neuralDole = new routes_api_remove.neuralDole({
|
var neuralDole = null
|
||||||
items: db.items, gauge: prometheusDoleFactorGauge
|
|
||||||
})
|
if(config.useNeuralNetDoleDivider)//Only initialize neural network when it's enabled, otherwise it might override gauge
|
||||||
|
neuralDole=new routes_api_remove.neuralDole({
|
||||||
|
items: db.items, gaugePrefix: prometheusPrefix
|
||||||
|
})
|
||||||
/**
|
/**
|
||||||
POST endpoint to remove items from DB when client orders items.
|
POST endpoint to remove items from DB when client orders items.
|
||||||
|
|
||||||
@@ -564,7 +567,7 @@ app.post("/api/remove", authenticate.middleware, function(req, res) {
|
|||||||
if(slaves[object.instanceID]) object.instanceName = slaves[object.instanceID].instanceName;
|
if(slaves[object.instanceID]) object.instanceName = slaves[object.instanceID].instanceName;
|
||||||
let item = db.items[object.name]
|
let item = db.items[object.name]
|
||||||
// console.dir(doc);
|
// console.dir(doc);
|
||||||
if(!item
|
if((item === undefined)
|
||||||
||((
|
||((
|
||||||
config.disableImportsOfEverythingExceptElectricity === true || config.disableImportsOfEverythingExceptElectricity === "true" )
|
config.disableImportsOfEverythingExceptElectricity === true || config.disableImportsOfEverythingExceptElectricity === "true" )
|
||||||
&& object.name != "electricity")
|
&& object.name != "electricity")
|
||||||
|
|||||||
Reference in new issue
Block a user