From 1bf2e7cf181ca5b9e38c3a6a1a6ba2c24e79b8ef Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 6 Jun 2013 11:47:20 +0200 Subject: [PATCH] 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. --- public/include/classes/statistics.class.php | 8 +++++-- public/include/pages/statistics/user.inc.php | 1 - .../mmcFE/statistics/user/default.tpl | 22 ++++++++++++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index edbc24a0..a85cb145 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -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; diff --git a/public/include/pages/statistics/user.inc.php b/public/include/pages/statistics/user.inc.php index 2a713925..2b0b0ed9 100644 --- a/public/include/pages/statistics/user.inc.php +++ b/public/include/pages/statistics/user.inc.php @@ -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"); diff --git a/public/templates/mmcFE/statistics/user/default.tpl b/public/templates/mmcFE/statistics/user/default.tpl index dee8180e..201c783c 100644 --- a/public/templates/mmcFE/statistics/user/default.tpl +++ b/public/templates/mmcFE/statistics/user/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)}
-{section hashrate $YOURHASHRATES} - -{/section} +{for $i=date('G', time() + 60 * 60) to 23} + +{/for} +{for $i=0 to date('G')} + +{/for} -{section hashrate $YOURHASHRATES} - -{/section} +{for $i=date('G', time() + 60 * 60) to 23} + +{/for} +{for $i=0 to date('G')} + +{/for}
Your Hashrate 
{$YOURHASHRATES[hashrate].hour}{$i}{$i}
{$GLOBAL.USERDATA.username}{$YOURHASHRATES[hashrate].hashrate}{$YOURHASHRATES.$i|default:"0"}{$YOURHASHRATES.$i|default:"0"}
+{else} +

  • No shares available to start calculations
  • +{/if} {include file="global/block_footer.tpl"}