adding special getRoundShares for statistics into stats class
This commit is contained in:
parent
993c4f363a
commit
0e7f7d75f2
@ -67,6 +67,28 @@ class Statistics {
|
|||||||
return false;
|
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) {
|
private function checkStmt($bState) {
|
||||||
if ($bState ===! true) {
|
if ($bState ===! true) {
|
||||||
$this->debug->append("Failed to prepare statement: " . $this->mysqli->error);
|
$this->debug->append("Failed to prepare statement: " . $this->mysqli->error);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ $debug->append('Global smarty variables', 3);
|
|||||||
|
|
||||||
if (!$aRoundShares = $memcache->get('aRoundShares')) {
|
if (!$aRoundShares = $memcache->get('aRoundShares')) {
|
||||||
$debug->append('Fetching aRoundShares from database');
|
$debug->append('Fetching aRoundShares from database');
|
||||||
$aRoundShares = $share->getRoundShares();
|
$aRoundShares = $statistics->getRoundShares();
|
||||||
$memcache->set('aRoundShares', $aRoundShares, 60);
|
$memcache->set('aRoundShares', $aRoundShares, 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user