adding special getRoundShares for statistics into stats class

This commit is contained in:
Sebastian Grewe 2013-05-14 18:08:47 +02:00
parent 993c4f363a
commit 0e7f7d75f2
2 changed files with 23 additions and 1 deletions

View File

@ -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);

View File

@ -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);
}