From 39d1193e6a59358843847185fc104cf347a9227b Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 11 Jul 2013 08:51:40 +0200 Subject: [PATCH 1/2] Add default value for active pool workers Fixes #418 --- public/templates/mmcFE/global/header.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/global/header.tpl b/public/templates/mmcFE/global/header.tpl index b3d150f6..4ee9d9b5 100644 --- a/public/templates/mmcFE/global/header.tpl +++ b/public/templates/mmcFE/global/header.tpl @@ -8,7 +8,7 @@
  • Network Hashrate: {($GLOBAL.nethashrate / 1000 / 1000 )|default:"0"|number_format:"3"} MH/s    
  • Pool Hashrate: {($GLOBAL.hashrate / 1000)|number_format:"3"} MH/s    
  • Pool Sharerate: {$GLOBAL.sharerate|number_format:"2"} Shares/s    
  • -
  • Pool Workers: {$GLOBAL.workers}    
  • +
  • Pool Workers: {$GLOBAL.workers|default:"0"}    
  • From 1344f39f9617ad346f5485656b32a413065be745 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 11 Jul 2013 11:43:48 +0200 Subject: [PATCH 2/2] Ensure we set workers to 0 If no workers are found false is returned. Smarty is not able to set a default on `false` values so we have to set it to 0 if the query failed. Fixes #418 --- public/include/classes/worker.class.php | 10 ++-------- public/include/smarty_globals.inc.php | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index ec7abdc9..7643a6d1 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -135,15 +135,9 @@ class Worker { **/ public function getCountAllActiveWorkers() { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare("SELECT COUNT(DISTINCT username) AS total FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)"); - if ($this->checkStmt($stmt)) { - if (!$stmt->execute()) { - return false; - } - $result = $stmt->get_result(); - $stmt->close(); + $stmt = $this->mysqli->prepare("SELECT IFNULL(COUNT(DISTINCT username), 0) AS total FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)"); + if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->total; - } return false; } diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index e83b1ca3..33c5fda7 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -24,7 +24,7 @@ if (@$_SESSION['AUTHENTICATED']) { $bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0; // Fetch some data -$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers(); +if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActiveWorkers = 0; $iCurrentPoolHashrate = $statistics->getCurrentHashrate(); $iCurrentPoolShareRate = $statistics->getCurrentShareRate();