Merge pull request #607 from TheSerapher/issue-606

Issue 606
This commit is contained in:
Sebastian Grewe 2013-08-15 01:06:22 -07:00
commit 405451d67a
4 changed files with 32 additions and 50 deletions

View File

@ -402,10 +402,11 @@ class Statistics {
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()) {
$aData = array();
while ($row = $result->fetch_assoc()) {
$aData[$row['hour']] = $row['hashrate'];
}
$iStartHour = date('G');
for ($i = $iStartHour; $i < 24; $i++) $aData[$i] = 0;
while ($row = $result->fetch_assoc()) $aData[$row['hour']] = $row['hashrate'];
// Fill any non-existing hours with 0 hashrate
for ($i = 0; $i < 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0;
return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData);
}
// Catchall
@ -438,10 +439,12 @@ class Statistics {
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);
$iStartHour = date('G');
for ($i = $iStartHour; $i < 24; $i++) $aData[$i] = 0;
while ($row = $result->fetch_assoc()) $aData[$row['hour']] = (int) $row['hashrate'];
// Fill any non-existing hours with 0 hashrate
for ($i = 0; $i < 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0;
return $this->memcache->setCache(__FUNCTION__, $aData);
}
// Catchall
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);

View File

@ -5,32 +5,23 @@
<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}
{foreach $YOURHASHRATES as $hour=>$hashrate}
<th scope="col">{$hour|default:"0"}:00</th>
{/foreach}
</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}
{foreach $YOURHASHRATES as $hour=>$hashrate}
<td>{$hashrate|default:"0"}</td>
{/foreach}
</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}
{foreach $POOLHASHRATES as $hour=>$hashrate}
<td>{$hashrate|default:"0"}</td>
{/foreach}
</tr>
</tbody>
</table>

View File

@ -5,23 +5,17 @@
<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}
{foreach $YOURHASHRATES as $hour=>$hashrate}
<th scope="col">{$hour|default:"0"}:00</th>
{/foreach}
</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}
{foreach $YOURHASHRATES as $hour=>$hashrate}
<td>{$hashrate|default:"0"}</td>
{/foreach}
</tr>
</tbody>
</table>

View File

@ -5,23 +5,17 @@
<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}
{foreach $POOLHASHRATES as $hour=>$hashrate}
<th scope="col">{$hour|default:"0"}:00</th>
{/foreach}
</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}
{foreach $POOLHASHRATES as $hour=>$hashrate}
<td>{$hashrate|default:"0"}</td>
{/foreach}
</tr>
</tbody>
</table>