First version for new user graphs

* Properly calculate hashrate
* Remove number formatting, it breaks the graph
* Not properly in order based on time but displays correct values

Addresses #90
This commit is contained in:
Sebastian Grewe 2013-06-05 17:22:47 +02:00
parent 0ad2069275
commit 7dc0736b77
3 changed files with 13 additions and 23 deletions

View File

@ -302,7 +302,7 @@ class Statistics {
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data; if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
$stmt = $this->mysqli->prepare(" $stmt = $this->mysqli->prepare("
SELECT 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 HOUR(s.time) AS hour
FROM " . $this->share->getTableName() . " AS s, accounts AS a FROM " . $this->share->getTableName() . " AS s, accounts AS a
WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR
@ -311,7 +311,7 @@ class Statistics {
GROUP BY HOUR(time) GROUP BY HOUR(time)
UNION ALL UNION ALL
SELECT 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 HOUR(s.time) AS hour
FROM " . $this->share->getArchiveTableName() . " AS s, accounts AS a FROM " . $this->share->getArchiveTableName() . " AS s, accounts AS a
WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR WHERE time < NOW() - INTERVAL 1 HOUR AND time > NOW() - INTERVAL 25 HOUR

View File

@ -4,16 +4,6 @@
if (!defined('SECURITY')) if (!defined('SECURITY'))
die('Hacking attempt'); 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']); $aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA']['id']);
// Propagate content our template // Propagate content our template

View File

@ -14,7 +14,7 @@
<tr> <tr>
<th scope="row">{$GLOBAL.USERDATA.username}</th> <th scope="row">{$GLOBAL.USERDATA.username}</th>
{section hashrate $YOURHASHRATES} {section hashrate $YOURHASHRATES}
<td>{$YOURHASHRATES[hashrate].hashrate|number_format}</td> <td>{$YOURHASHRATES[hashrate].hashrate}</td>
{/section} {/section}
</tr> </tr>
</tbody> </tbody>