mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Tweaked slaveDisplay.js to use 92% less data to draw a chart. This is projected to speed up chart loading significantly, from 3.4s to about 0.5s.
- Added copper-cable to the list of hidables on the chart, and removed copper-wire which isn't a thing. - Don't display items as hidable that aren't being produced. It's confusing. - Added /getTimelineStats, because /getStats is used by another view that I don't feel like converting to not require the 0-production data points.
This commit is contained in:
1 parent
000b2fc147
commit
49887012f7
2 files changed
+76
-32
No files matched your search
@@ -307,6 +307,49 @@ app.post("/api/getStats", function(req,res) {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Modified version of getStats which feeds the web interface production graphs
|
||||
// at /nodes. It is like getStats but it does not report items which were not
|
||||
// produced at the moment of recording. (This is to save space, the 0-items were
|
||||
// making up about 92% of the response body weight.)
|
||||
app.post("/api/getTimelineStats", function(req,res) {
|
||||
console.log(req.body);
|
||||
if(typeof req.body == "object" && req.body.slaveID) {
|
||||
// if not specified, get stats for last 24 hours
|
||||
if(!req.body.fromTime) {
|
||||
req.body.fromTime = Date.now() - 86400000 // 24 hours in MS
|
||||
}
|
||||
if(!req.body.toTime) {
|
||||
req.body.toTime = Date.now();
|
||||
}
|
||||
console.log("Looking... " + JSON.stringify(req.body));
|
||||
db.flows.find({
|
||||
slaveID: req.body.slaveID,
|
||||
}, function(err, docs) {
|
||||
if(err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
//Filter out all the entries outside the time range.
|
||||
docs = docs.filter(function (el) {
|
||||
return el.timestamp <= req.body.toTime && el.timestamp >= req.body.fromTime;
|
||||
});
|
||||
|
||||
//Filter out all the elements that weren't produced.
|
||||
docs.forEach(el => {
|
||||
for(let key in el.data) {
|
||||
if(el.data[key] === '0') {
|
||||
delete el.data[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
res.send(docs);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/api/getFactorioLocale", function(req,res){
|
||||
getFactorioLocale.asObject(config.factorioDirectory, "en", (err, factorioLocale) => res.send(factorioLocale));
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user