diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 7ddbf57d..5154e136 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -67,6 +67,28 @@ class Statistics { return false; } + public function getRoundShares() { + $stmt = $this->mysqli->prepare(" + SELECT + ( SELECT IFNULL(count(id), 0) + FROM " . $this->share->getTableName() . " + WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0) + AND our_result = 'Y' ) as valid, + ( SELECT IFNULL(count(id), 0) + FROM " . $this->share->getTableName() . " + WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0) + AND our_result = 'N' ) as invalid + "); + if ($this->checkStmt($stmt)) { + + $stmt->execute(); + $result = $stmt->get_result(); + $stmt->close(); + return $result->fetch_assoc(); + } + return false; + } + private function checkStmt($bState) { if ($bState ===! true) { $this->debug->append("Failed to prepare statement: " . $this->mysqli->error); diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index b707e0d9..764afb3a 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -9,7 +9,7 @@ $debug->append('Global smarty variables', 3); if (!$aRoundShares = $memcache->get('aRoundShares')) { $debug->append('Fetching aRoundShares from database'); - $aRoundShares = $share->getRoundShares(); + $aRoundShares = $statistics->getRoundShares(); $memcache->set('aRoundShares', $aRoundShares, 60); }