From d3f8aee812d810e8e2c5821e1b5956a90c67557f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 7 Jan 2021 05:45:44 +0200 Subject: [PATCH] Fixed calculateGlobal --- client/datastore.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/client/datastore.js b/client/datastore.js index 0ae5c68..264ff69 100644 --- a/client/datastore.js +++ b/client/datastore.js @@ -26,7 +26,7 @@ module.exports = class { calculateGlobal(client){ let guilds = this.map.keys(); let stations = client.stations; - let statistics = {}; + var statistics = {}; if(!client.stations) return; @@ -34,23 +34,21 @@ module.exports = class { while (!calculation.done) { let currentGuild = this.getEntry(calculation.value); - if(calculation.value == 'global'){ - return calculation = guilds.next(); - } - - 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; + 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); } - - 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(); }