diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index c261a884..4ed74bb4 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -302,24 +302,21 @@ class Statistics { if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data; $stmt = $this->mysqli->prepare(" SELECT - ROUND(COUNT(s.id) * POW(2, 12)/600/1000) AS hashrate, + ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate, HOUR(s.time) AS hour - FROM " . $this->share->getTableName() . " AS s, accounts AS a - WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR + FROM " . $this->share->getTableName() . " AS s, accounts AS a + WHERE time < NOW() - INTERVAL 1 HOUR + AND time > NOW() - INTERVAL 25 HOUR AND a.username = SUBSTRING_INDEX( s.username, '.', 1 ) AND a.id = ? - GROUP BY HOUR(time) - UNION ALL - SELECT - ROUND(COUNT(s.id) * POW(2, 12)/600/1000) AS hashrate, - HOUR(s.time) AS hour - FROM " . $this->share->getArchiveTableName() . " AS s, accounts AS a - WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR - AND a.username = SUBSTRING_INDEX( s.username, '.', 1 ) - AND a.id = ? - GROUP BY HOUR(time)"); - if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $account_id, $account_id) && $stmt->execute() && $result = $stmt->get_result()) - return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_all(MYSQLI_ASSOC), 3600); + GROUP BY HOUR(time) + "); + if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result()) { + while ($row = $result->fetch_assoc()) { + $aData[$row['hour']] = $row['hashrate']; + } + return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData); + } // Catchall $this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error); return false; diff --git a/public/include/pages/statistics/user.inc.php b/public/include/pages/statistics/user.inc.php index 41440b99..2b0b0ed9 100644 --- a/public/include/pages/statistics/user.inc.php +++ b/public/include/pages/statistics/user.inc.php @@ -4,21 +4,10 @@ if (!defined('SECURITY')) die('Hacking attempt'); -// Fetch data from litecoind -if ($bitcoin->can_connect() === true){ - $dDifficulty = $bitcoin->getdifficulty(); - $iBlock = $bitcoin->getblockcount(); -} else { - $iDifficulty = 1; - $iBlock = 0; - $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to litecoind RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg'); -} - $aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA']['id']); // Propagate content our template $smarty->assign("YOURHASHRATES", $aHourlyHashRates); -$smarty->assign("DIFFICULTY", $dDifficulty); if ($_SESSION['AUTHENTICATED']) { $smarty->assign("CONTENT", "default.tpl"); diff --git a/public/templates/mmcFE/statistics/user/default.tpl b/public/templates/mmcFE/statistics/user/default.tpl index ffc5e8c8..dc285321 100644 --- a/public/templates/mmcFE/statistics/user/default.tpl +++ b/public/templates/mmcFE/statistics/user/default.tpl @@ -1,23 +1,33 @@ {include file="global/block_header.tpl" BLOCK_HEADER="Your Average Hourly Hash Rate" BUTTONS=array(mine,pool,both)} +{if is_array($YOURHASHRATES)}
| -{section hashrate $YOURHASHRATES} - | {$YOURHASHRATES[hashrate].hour} | -{/section} +{for $i=date('G') to 23} +{$i}:00 | +{/for} +{for $i=0 to date('G', time () - 60 * 60)} +{$i}:00 | +{/for}|
|---|---|---|---|---|
| {$GLOBAL.USERDATA.username} | -{section hashrate $YOURHASHRATES} -{$YOURHASHRATES[hashrate].hashrate|number_format} | -{/section} +{$smarty.session.USERDATA.username} | +{for $i=date('G') to 23} +{$YOURHASHRATES.$i|default:"0"} | +{/for} +{for $i=0 to date('G', time() - 60 * 60)} +{$YOURHASHRATES.$i|default:"0"} | +{/for}