Merge pull request #188 from TheSerapher/issue-187
Adding pool and combined hashrate graphs
This commit is contained in:
commit
627bc5b47e
@ -293,7 +293,6 @@ class Statistics {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get Hourly hashrate for a user
|
* get Hourly hashrate for a user
|
||||||
* Not working yet since I was not able to solve this via SQL queries
|
|
||||||
* @param account_id int User ID
|
* @param account_id int User ID
|
||||||
* @return data array NOT FINISHED YET
|
* @return data array NOT FINISHED YET
|
||||||
**/
|
**/
|
||||||
@ -321,6 +320,34 @@ class Statistics {
|
|||||||
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
|
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Hourly hashrate for the pool
|
||||||
|
* @param none
|
||||||
|
* @return data array NOT FINISHED YET
|
||||||
|
**/
|
||||||
|
public function getHourlyHashrateByPool() {
|
||||||
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
|
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||||
|
$stmt = $this->mysqli->prepare("
|
||||||
|
SELECT
|
||||||
|
ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate,
|
||||||
|
HOUR(s.time) AS hour
|
||||||
|
FROM " . $this->share->getTableName() . " AS s
|
||||||
|
WHERE time < NOW() - INTERVAL 1 HOUR
|
||||||
|
AND time > NOW() - INTERVAL 25 HOUR
|
||||||
|
GROUP BY HOUR(time)
|
||||||
|
");
|
||||||
|
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$aData[$row['hour']] = $row['hashrate'];
|
||||||
|
}
|
||||||
|
return $this->memcache->setCache(__FUNCTION__, $aData);
|
||||||
|
}
|
||||||
|
// Catchall
|
||||||
|
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$statistics = new Statistics($debug, $mysqli, $config, $share, $user, $block, $memcache);
|
$statistics = new Statistics($debug, $mysqli, $config, $share, $user, $block, $memcache);
|
||||||
|
|||||||
@ -6,8 +6,10 @@ if (!defined('SECURITY'))
|
|||||||
|
|
||||||
if ($user->isAuthenticated()) {
|
if ($user->isAuthenticated()) {
|
||||||
$aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA']['id']);
|
$aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA']['id']);
|
||||||
|
$aPoolHourlyHashRates = $statistics->getHourlyHashrateByPool();
|
||||||
// Propagate content our template
|
// Propagate content our template
|
||||||
$smarty->assign("YOURHASHRATES", $aHourlyHashRates);
|
$smarty->assign("YOURHASHRATES", $aHourlyHashRates);
|
||||||
|
$smarty->assign("POOLHASHRATES", $aPoolHourlyHashRates);
|
||||||
$smarty->assign("CONTENT", "default.tpl");
|
$smarty->assign("CONTENT", "default.tpl");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -5,7 +5,6 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=edit">Edit Account</a></li>
|
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=edit">Edit Account</a></li>
|
||||||
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=workers">My Workers</a></li>
|
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=workers">My Workers</a></li>
|
||||||
<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=user">My Graphs</a></li>
|
|
||||||
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=transactions">Transactions</a></li>
|
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=transactions">Transactions</a></li>
|
||||||
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=notifications">Notifications</a></li>
|
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=notifications">Notifications</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -23,6 +22,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=pool">Pool Stats</a></li>
|
<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=pool">Pool Stats</a></li>
|
||||||
{if $smarty.session.AUTHENTICATED|default}<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=blocks">Block Stats</a></li>{/if}
|
{if $smarty.session.AUTHENTICATED|default}<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=blocks">Block Stats</a></li>{/if}
|
||||||
|
{if $smarty.session.AUTHENTICATED|default}<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=graphs">Hashrate Graphs</a></li>{/if}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="{$smarty.server.PHP_SELF}?page=gettingstarted">Getting Started</a></li>
|
<li><a href="{$smarty.server.PHP_SELF}?page=gettingstarted">Getting Started</a></li>
|
||||||
|
|||||||
43
public/templates/mmcFE/statistics/graphs/both.tpl
Normal file
43
public/templates/mmcFE/statistics/graphs/both.tpl
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{if is_array($YOURHASHRATES) && is_array($POOLHASHRATES)}
|
||||||
|
<div class="block_content tab_content" id="both" style="padding-left:30px;">
|
||||||
|
{foreach from=array('area','pie') item=chartType}
|
||||||
|
<table width="60%" class="stats" rel="{$chartType}">
|
||||||
|
<caption>Your vs Pool Hashrate</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
{for $i=date('G') to 23}
|
||||||
|
<th scope="col">{$i}:00</th>
|
||||||
|
{/for}
|
||||||
|
{for $i=0 to date('G', time () - 60 * 60)}
|
||||||
|
<th scope="col">{$i}:00</th>
|
||||||
|
{/for}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{$smarty.session.USERDATA.username}</th>
|
||||||
|
{for $i=date('G') to 23}
|
||||||
|
<td>{$YOURHASHRATES.$i|default:"0"}</td>
|
||||||
|
{/for}
|
||||||
|
{for $i=0 to date('G', time() - 60 * 60)}
|
||||||
|
<td>{$YOURHASHRATES.$i|default:"0"}</td>
|
||||||
|
{/for}
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Pool</th>
|
||||||
|
{for $i=date('G') to 23}
|
||||||
|
<td>{$POOLHASHRATES.$i|default:"0"}</td>
|
||||||
|
{/for}
|
||||||
|
{for $i=0 to date('G', time() - 60 * 60)}
|
||||||
|
<td>{$POOLHASHRATES.$i|default:"0"}</td>
|
||||||
|
{/for}
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
{/foreach}
|
||||||
|
</div>
|
||||||
|
{else}
|
||||||
|
<p><li>No shares available to start calculations</li></p>
|
||||||
|
{/if}
|
||||||
5
public/templates/mmcFE/statistics/graphs/default.tpl
Normal file
5
public/templates/mmcFE/statistics/graphs/default.tpl
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{include file="global/block_header.tpl" BLOCK_HEADER="24h Hashrate Statistics" BUTTONS=array(mine,pool,both)}
|
||||||
|
{include file="{$smarty.request.page}/{$smarty.request.action}/mine.tpl"}
|
||||||
|
{include file="{$smarty.request.page}/{$smarty.request.action}/pool.tpl"}
|
||||||
|
{include file="{$smarty.request.page}/{$smarty.request.action}/both.tpl"}
|
||||||
|
{include file="global/block_footer.tpl"}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
{include file="global/block_header.tpl" BLOCK_HEADER="Your Average Hourly Hash Rate" BUTTONS=array(mine,pool,both)}
|
|
||||||
{if is_array($YOURHASHRATES)}
|
{if is_array($YOURHASHRATES)}
|
||||||
<div class="block_content tab_content" id="mine" style="padding-left:30px;">
|
<div class="block_content tab_content" id="mine" style="padding-left:30px;">
|
||||||
<table width="60%" class="stats" rel="area">
|
<table width="60%" class="stats" rel="area">
|
||||||
@ -30,4 +29,3 @@
|
|||||||
{else}
|
{else}
|
||||||
<p><li>No shares available to start calculations</li></p>
|
<p><li>No shares available to start calculations</li></p>
|
||||||
{/if}
|
{/if}
|
||||||
{include file="global/block_footer.tpl"}
|
|
||||||
31
public/templates/mmcFE/statistics/graphs/pool.tpl
Normal file
31
public/templates/mmcFE/statistics/graphs/pool.tpl
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{if is_array($POOLHASHRATES)}
|
||||||
|
<div class="block_content tab_content" id="pool" style="padding-left:30px;">
|
||||||
|
<table width="60%" class="stats" rel="area">
|
||||||
|
<caption>Pool Hashrate</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
{for $i=date('G') to 23}
|
||||||
|
<th scope="col">{$i}:00</th>
|
||||||
|
{/for}
|
||||||
|
{for $i=0 to date('G', time () - 60 * 60)}
|
||||||
|
<th scope="col">{$i}:00</th>
|
||||||
|
{/for}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Pool</th>
|
||||||
|
{for $i=date('G') to 23}
|
||||||
|
<td>{$POOLHASHRATES.$i|default:"0"}</td>
|
||||||
|
{/for}
|
||||||
|
{for $i=0 to date('G', time() - 60 * 60)}
|
||||||
|
<td>{$POOLHASHRATES.$i|default:"0"}</td>
|
||||||
|
{/for}
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{else}
|
||||||
|
<p><li>No shares available to start calculations</li></p>
|
||||||
|
{/if}
|
||||||
Loading…
Reference in New Issue
Block a user