Fixed calculateGlobal

This commit is contained in:
Christer Warén 2021-01-07 05:45:44 +02:00
parent b9ad745770
commit d3f8aee812

View File

@ -26,7 +26,7 @@ module.exports = class {
calculateGlobal(client){ calculateGlobal(client){
let guilds = this.map.keys(); let guilds = this.map.keys();
let stations = client.stations; let stations = client.stations;
let statistics = {}; var statistics = {};
if(!client.stations) return; if(!client.stations) return;
@ -34,13 +34,10 @@ module.exports = class {
while (!calculation.done) { while (!calculation.done) {
let currentGuild = this.getEntry(calculation.value); let currentGuild = this.getEntry(calculation.value);
if(calculation.value == 'global'){ if(calculation.value != 'global'){
return calculation = guilds.next();
}
if(stations){ if(stations){
Object.keys(stations).forEach(function(station) { 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(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]){ if(!statistics[stations[station].name]){
statistics[stations[station].name] = {}; statistics[stations[station].name] = {};
statistics[stations[station].name].time = 0; statistics[stations[station].name].time = 0;
@ -52,6 +49,7 @@ module.exports = class {
} }
}); });
} }
}
calculation = guilds.next(); calculation = guilds.next();
} }