diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php
index 3bcebcfb..46ab5cb5 100644
--- a/public/include/classes/statistics.class.php
+++ b/public/include/classes/statistics.class.php
@@ -293,7 +293,6 @@ class Statistics {
/**
* get Hourly hashrate for a user
- * Not working yet since I was not able to solve this via SQL queries
* @param account_id int User ID
* @return data array NOT FINISHED YET
**/
@@ -321,6 +320,34 @@ class Statistics {
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
return false;
}
+
+ /**
+ * get Hourly hashrate for the pool
+ * @param none
+ * @return data array NOT FINISHED YET
+ **/
+ public function getHourlyHashrateByPool() {
+ $this->debug->append("STA " . __METHOD__, 4);
+ if ($data = $this->memcache->get(__FUNCTION__)) return $data;
+ $stmt = $this->mysqli->prepare("
+ SELECT
+ ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate,
+ HOUR(s.time) AS hour
+ FROM " . $this->share->getTableName() . " AS s
+ WHERE time < NOW() - INTERVAL 1 HOUR
+ 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);
+ }
+ // Catchall
+ $this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
+ return false;
+ }
}
$statistics = new Statistics($debug, $mysqli, $config, $share, $user, $block, $memcache);
diff --git a/public/include/pages/statistics/user.inc.php b/public/include/pages/statistics/graphs.inc.php
similarity index 74%
rename from public/include/pages/statistics/user.inc.php
rename to public/include/pages/statistics/graphs.inc.php
index 13b3ba5b..cf62bddf 100644
--- a/public/include/pages/statistics/user.inc.php
+++ b/public/include/pages/statistics/graphs.inc.php
@@ -6,8 +6,10 @@ if (!defined('SECURITY'))
if ($user->isAuthenticated()) {
$aHourlyHashRates = $statistics->getHourlyHashrateByAccount($_SESSION['USERDATA']['id']);
+ $aPoolHourlyHashRates = $statistics->getHourlyHashrateByPool();
// Propagate content our template
$smarty->assign("YOURHASHRATES", $aHourlyHashRates);
+ $smarty->assign("POOLHASHRATES", $aPoolHourlyHashRates);
$smarty->assign("CONTENT", "default.tpl");
}
?>
diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl
index 9beb87cb..c53f61c7 100644
--- a/public/templates/mmcFE/global/navigation.tpl
+++ b/public/templates/mmcFE/global/navigation.tpl
@@ -5,7 +5,6 @@
+{foreach from=array('area','pie') item=chartType}
+
+ Your vs Pool Hashrate
+
+
+ |
+{for $i=date('G') to 23}
+ {$i}:00 |
+{/for}
+{for $i=0 to date('G', time () - 60 * 60)}
+ {$i}:00 |
+{/for}
+
+
+
+
+ | {$smarty.session.USERDATA.username} |
+{for $i=date('G') to 23}
+ {$YOURHASHRATES.$i|default:"0"} |
+{/for}
+{for $i=0 to date('G', time() - 60 * 60)}
+ {$YOURHASHRATES.$i|default:"0"} |
+{/for}
+
+
+ | Pool |
+{for $i=date('G') to 23}
+ {$POOLHASHRATES.$i|default:"0"} |
+{/for}
+{for $i=0 to date('G', time() - 60 * 60)}
+ {$POOLHASHRATES.$i|default:"0"} |
+{/for}
+
+
+
+
+{/foreach}
+
+{else}
+