Pre-sort SQL data in array for easy time access
This allows us to access the array key as the time. This way the template can properly render the time axis according to current time.
This commit is contained in:
parent
232e79f7ad
commit
1bf2e7cf18
@ -311,8 +311,12 @@ class Statistics {
|
||||
AND a.id = ?
|
||||
GROUP BY HOUR(time)
|
||||
");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_all(MYSQLI_ASSOC), 3600);
|
||||
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, 3600);
|
||||
}
|
||||
// Catchall
|
||||
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
|
||||
return false;
|
||||
|
||||
@ -8,7 +8,6 @@ $aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA'
|
||||
|
||||
// Propagate content our template
|
||||
$smarty->assign("YOURHASHRATES", $aHourlyHashRates);
|
||||
$smarty->assign("DIFFICULTY", $dDifficulty);
|
||||
|
||||
if ($_SESSION['AUTHENTICATED']) {
|
||||
$smarty->assign("CONTENT", "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)}
|
||||
<div class="block_content tab_content" id="mine" style="padding-left:30px;">
|
||||
<table class="stats" rel="area" cellpadding="0">
|
||||
<caption>Your Hashrate </caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td></td>
|
||||
{section hashrate $YOURHASHRATES}
|
||||
<th scope="col">{$YOURHASHRATES[hashrate].hour}</th>
|
||||
{/section}
|
||||
{for $i=date('G', time() + 60 * 60) to 23}
|
||||
<th scope="col">{$i}</th>
|
||||
{/for}
|
||||
{for $i=0 to date('G')}
|
||||
<th scope="col">{$i}</th>
|
||||
{/for}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">{$GLOBAL.USERDATA.username}</th>
|
||||
{section hashrate $YOURHASHRATES}
|
||||
<td>{$YOURHASHRATES[hashrate].hashrate}</td>
|
||||
{/section}
|
||||
{for $i=date('G', time() + 60 * 60) to 23}
|
||||
<td>{$YOURHASHRATES.$i|default:"0"}</td>
|
||||
{/for}
|
||||
{for $i=0 to date('G')}
|
||||
<td>{$YOURHASHRATES.$i|default:"0"}</td>
|
||||
{/for}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{else}
|
||||
<p><li>No shares available to start calculations</li></p>
|
||||
{/if}
|
||||
{include file="global/block_footer.tpl"}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user