diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php
index 1452db89..e4e06167 100644
--- a/public/include/classes/statistics.class.php
+++ b/public/include/classes/statistics.class.php
@@ -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);
diff --git a/public/templates/mmcFE/statistics/graphs/both.tpl b/public/templates/mmcFE/statistics/graphs/both.tpl
index 878a5b4d..a8011e90 100644
--- a/public/templates/mmcFE/statistics/graphs/both.tpl
+++ b/public/templates/mmcFE/statistics/graphs/both.tpl
@@ -5,32 +5,23 @@
-{for $i=date('G') to 23}
- {$i}:00
-{/for}
-{for $i=0 to date('G', time () - 60 * 60)}
- {$i}:00
-{/for}
+{foreach $YOURHASHRATES as $hour=>$hashrate}
+ {$hour|default:"0"}:00
+{/foreach}