diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 2960bfe7..f77a74b3 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -181,28 +181,46 @@ class Worker { * @param limit int * @return mixed array Workers and their settings or false **/ - public function getAllWorkers($iLimit=0) { + public function getAllWorkers($iLimit=0, $interval=600) { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" - SELECT id, username, password, monitor, difficulty, + SELECT id, username, password, monitor, + IFNULL(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0) AS difficulty, ( SELECT - IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0), 0) AS hashrate + IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / ? / 1000), 0), 0) AS hashrate FROM " . $this->share->getTableName() . " WHERE username = w.username - AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) - ) + ( - SELECT - IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0), 0) AS hashrate + AND time > DATE_SUB(now(), INTERVAL ? SECOND) + ) + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / ? / 1000), 0), 0) AS hashrate FROM " . $this->share->getArchiveTableName() . " WHERE username = w.username - AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) - ) AS hashrate + AND time > DATE_SUB(now(), INTERVAL ? SECOND) + ) AS hashrate, + (( + SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)), 2), 0) + FROM " . $this->share->getTableName() . " + WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND) + ) + ( + SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)), 2), 0) + FROM " . $this->share->getArchiveTableName() . " + WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND) + )) / (( + SELECT COUNT(id) + FROM " . $this->share->getTableName() . " + WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND) + ) + ( + SELECT COUNT(id) + FROM " . $this->share->getArchiveTableName() . " + WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND) + )) AS avg_difficulty FROM $this->table AS w ORDER BY hashrate DESC LIMIT ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iLimit) && $stmt->execute() && $result = $stmt->get_result()) + if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiiiiii', $interval, $interval, $interval, $interval, $interval, $interval, $interval, $interval, $iLimit) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); // Catchall $this->setErrorMessage('Failed to fetch workers'); diff --git a/public/templates/mmcFE/admin/poolworkers/default.tpl b/public/templates/mmcFE/admin/poolworkers/default.tpl index f7afe308..5a9fe375 100644 --- a/public/templates/mmcFE/admin/poolworkers/default.tpl +++ b/public/templates/mmcFE/admin/poolworkers/default.tpl @@ -9,6 +9,7 @@ {if $GLOBAL.config.disable_notifications != 1}Monitor{/if} Khash/s Difficulty + Avg Difficulty {nocache} @@ -25,6 +26,7 @@ {/if} {$WORKERS[worker].hashrate|number_format|default:"0"} {if $WORKERS[worker].hashrate > 0}{$WORKERS[worker].difficulty|number_format:"2"|default:"0"}{else}0{/if} + {if $WORKERS[worker].hashrate > 0}{$WORKERS[worker].avg_difficulty|number_format:"2"|default:"0"}{else}0{/if} {/section} {/nocache} diff --git a/public/templates/mpos/admin/poolworkers/default.tpl b/public/templates/mpos/admin/poolworkers/default.tpl index 5d721421..b9b7cc8a 100644 --- a/public/templates/mpos/admin/poolworkers/default.tpl +++ b/public/templates/mpos/admin/poolworkers/default.tpl @@ -8,7 +8,8 @@ Active {if $GLOBAL.config.disable_notifications != 1}Monitor{/if} Khash/s - Difficulty + Difficulty + Avg Difficulty {nocache} @@ -22,7 +23,8 @@ {/if} {$WORKERS[worker].hashrate|number_format|default:"0"} - {if $WORKERS[worker].hashrate > 0}{$WORKERS[worker].difficulty|number_format:"2"|default:"0"}{else}0{/if} + {if $WORKERS[worker].hashrate > 0}{$WORKERS[worker].difficulty|number_format:"2"|default:"0"}{else}0{/if} + {if $WORKERS[worker].hashrate > 0}{$WORKERS[worker].avg_difficulty|number_format:"2"|default:"0"}{else}0{/if} {/section} {/nocache}