diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index e4e06167..f6863c59 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -403,10 +403,10 @@ class Statistics { GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $account_id) && $stmt->execute() && $result = $stmt->get_result()) { $iStartHour = date('G'); - for ($i = $iStartHour; $i < 24; $i++) $aData[$i] = 0; + // Initilize array + for ($i = 0; $i < 24; $i++) $aData[($iStartHour + $i) % 24] = 0; + // Fill data 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 @@ -440,10 +440,10 @@ class Statistics { GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) { $iStartHour = date('G'); - for ($i = $iStartHour; $i < 24; $i++) $aData[$i] = 0; + // Initilize array + for ($i = 0; $i < 24; $i++) $aData[($iStartHour + $i) % 24] = 0; + // Fill data 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