Removed calculateGlobal function in Datastore class

This commit is contained in:
Christer Warén 2021-09-16 04:50:44 +03:00
parent 348b540c06
commit 7d38170ba6

View File

@ -27,47 +27,6 @@ module.exports = class {
//console.log(""); //console.log("");
} }
calculateGlobal(client){
if(!client.stations) return;
let guilds = this.map.keys();
let stations = client.stations;
var statistics = {};
if(!client.stations) return;
let calculation = guilds.next();
while (!calculation.done) {
let currentGuild = this.getEntry(calculation.value);
if(calculation.value != 'global'){
if(stations){
Object.keys(stations).forEach(function(station) {
if(currentGuild.statistics[stations[station].name] && currentGuild.statistics[stations[station].name].time && parseInt(currentGuild.statistics[stations[station].name].time) != 0 && currentGuild.statistics[stations[station].name].used && parseInt(currentGuild.statistics[stations[station].name].used) != 0){
if(!statistics[stations[station].name]){
statistics[stations[station].name] = {};
statistics[stations[station].name].time = 0;
statistics[stations[station].name].used = 0;
}
statistics[stations[station].name].time = parseInt(statistics[stations[station].name].time)+parseInt(currentGuild.statistics[stations[station].name].time);
statistics[stations[station].name].used = parseInt(statistics[stations[station].name].used)+parseInt(currentGuild.statistics[stations[station].name].used);
}
});
}
}
calculation = guilds.next();
}
let newData = {};
newData.guild = {};
newData.guild.id = "global";
newData.guild.name = "global";
newData.statistics = statistics;
this.updateEntry(newData.guild, newData);
}
checkEntry(id){ checkEntry(id){
this.loadEntry(id); this.loadEntry(id);
if(!this.map.has(id)){ if(!this.map.has(id)){