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 @@ @@ -23,6 +22,7 @@
  • Getting Started
  • diff --git a/public/templates/mmcFE/statistics/graphs/both.tpl b/public/templates/mmcFE/statistics/graphs/both.tpl new file mode 100644 index 00000000..ff760be1 --- /dev/null +++ b/public/templates/mmcFE/statistics/graphs/both.tpl @@ -0,0 +1,43 @@ +{if is_array($YOURHASHRATES) && is_array($POOLHASHRATES)} +
    +{foreach from=array('area','pie') item=chartType} + + + + + +{for $i=date('G') to 23} + +{/for} +{for $i=0 to date('G', time () - 60 * 60)} + +{/for} + + + + + +{for $i=date('G') to 23} + +{/for} +{for $i=0 to date('G', time() - 60 * 60)} + +{/for} + + + +{for $i=date('G') to 23} + +{/for} +{for $i=0 to date('G', time() - 60 * 60)} + +{/for} + + +
    Your vs Pool Hashrate
    {$i}:00{$i}:00
    {$smarty.session.USERDATA.username}{$YOURHASHRATES.$i|default:"0"}{$YOURHASHRATES.$i|default:"0"}
    Pool{$POOLHASHRATES.$i|default:"0"}{$POOLHASHRATES.$i|default:"0"}
    +
    +{/foreach} +
    +{else} +

  • No shares available to start calculations
  • +{/if} diff --git a/public/templates/mmcFE/statistics/graphs/default.tpl b/public/templates/mmcFE/statistics/graphs/default.tpl new file mode 100644 index 00000000..c325a4c6 --- /dev/null +++ b/public/templates/mmcFE/statistics/graphs/default.tpl @@ -0,0 +1,5 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="24h Hashrate Statistics" BUTTONS=array(mine,pool,both)} +{include file="{$smarty.request.page}/{$smarty.request.action}/mine.tpl"} +{include file="{$smarty.request.page}/{$smarty.request.action}/pool.tpl"} +{include file="{$smarty.request.page}/{$smarty.request.action}/both.tpl"} +{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/user/default.tpl b/public/templates/mmcFE/statistics/graphs/mine.tpl similarity index 83% rename from public/templates/mmcFE/statistics/user/default.tpl rename to public/templates/mmcFE/statistics/graphs/mine.tpl index debbd23a..fe217f2f 100644 --- a/public/templates/mmcFE/statistics/user/default.tpl +++ b/public/templates/mmcFE/statistics/graphs/mine.tpl @@ -1,4 +1,3 @@ -{include file="global/block_header.tpl" BLOCK_HEADER="Your Average Hourly Hash Rate" BUTTONS=array(mine,pool,both)} {if is_array($YOURHASHRATES)}
    @@ -30,4 +29,3 @@ {else}

  • No shares available to start calculations
  • {/if} -{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/graphs/pool.tpl b/public/templates/mmcFE/statistics/graphs/pool.tpl new file mode 100644 index 00000000..ba2ed4e5 --- /dev/null +++ b/public/templates/mmcFE/statistics/graphs/pool.tpl @@ -0,0 +1,31 @@ +{if is_array($POOLHASHRATES)} +
    +
    + + + + +{for $i=date('G') to 23} + +{/for} +{for $i=0 to date('G', time () - 60 * 60)} + +{/for} + + + + + +{for $i=date('G') to 23} + +{/for} +{for $i=0 to date('G', time() - 60 * 60)} + +{/for} + + +
    Pool Hashrate
    {$i}:00{$i}:00
    Pool{$POOLHASHRATES.$i|default:"0"}{$POOLHASHRATES.$i|default:"0"}
    +
    +{else} +

  • No shares available to start calculations
  • +{/if}