diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 7643a6d1..88999e1c 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -75,14 +75,15 @@ class Worker { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT account_id, id, username - FROM " . $this->table . " - WHERE monitor = 1 AND ( SELECT SIGN(COUNT(id)) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) = 0"); - + FROM " . $this->table . " AS w + WHERE monitor = 1 + AND ( + SELECT IFNULL(SIGN(IF(our_result = 'Y', COUNT(id), 0)), 0) FROM " . $this->share->getTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) = 0"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); // Catchall $this->setErrorMessage("Unable to fetch IDLE, monitored workers"); - echo $this->mysqli->error; return false; } @@ -95,15 +96,27 @@ class Worker { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT id, username, password, monitor, - ( SELECT SIGN(COUNT(id)) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS active, - ( SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate - FROM $this->table + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 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(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getArchiveTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) AS hashrate + FROM $this->table AS w WHERE id = ? "); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $id) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_assoc(); // Catchall - echo $this->mysqli->error; return false; } @@ -116,9 +129,22 @@ class Worker { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT id, username, password, monitor, - ( SELECT SIGN(COUNT(id)) FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' AND username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS active, - ( SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' AND username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate - FROM $this->table + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 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(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getArchiveTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) AS hashrate + FROM $this->table AS w WHERE account_id = ?"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); @@ -135,7 +161,7 @@ class Worker { **/ public function getCountAllActiveWorkers() { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare("SELECT IFNULL(COUNT(DISTINCT username), 0) AS total FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)"); + $stmt = $this->mysqli->prepare("SELECT IFNULL(IF(our_result='Y', COUNT(DISTINCT username), 0), 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/templates/mmcFE/account/workers/default.tpl b/public/templates/mmcFE/account/workers/default.tpl index 85862cf5..65635b4b 100644 --- a/public/templates/mmcFE/account/workers/default.tpl +++ b/public/templates/mmcFE/account/workers/default.tpl @@ -19,9 +19,9 @@ {section worker $WORKERS} {assign var="username" value="."|escape|explode:$WORKERS[worker].username:2}

