graphs: handle the new blake unit

This commit is contained in:
Tanguy Pruvot 2016-03-27 23:40:50 +02:00
parent fe6c79ea23
commit 1c5daaa9b7
8 changed files with 151 additions and 95 deletions

View file

@ -23,6 +23,7 @@ function bleutrade_api_query($method, $params='')
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("apisign:$sign"));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSLVERSION, 1 /*CURL_SSLVERSION_TLSv1*/);

View file

@ -5,16 +5,16 @@ $algo = user()->getState('yaamp-algo');
$t = time() - 48*60*60;
$stats = getdbolist('db_hashstats', "time>$t and algo=:algo", array(':algo'=>$algo));
echo '[';
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
$data = array();
foreach($stats as $i=>$n)
{
$m = round($n->hashrate/1000000, 3);
$m = round($n->hashrate/(1000000*$algo_unit_factor), 3);
if($i) echo ',';
$d = date('Y-m-d H:i:s', $n->time);
echo "[\"$d\",$m]";
$data[] = array($d, $m);
}
echo ']';
echo json_encode($data);

View file

@ -5,11 +5,13 @@ $algo = user()->getState('yaamp-algo');
$t = time() - 48*60*60;
$stats = getdbolist('db_hashstats', "time>$t and algo=:algo", array(':algo'=>$algo));
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
echo '[';
foreach($stats as $i=>$n)
{
$m = $n->hashrate? bitcoinvaluetoa($n->earnings*24*1000000/$n->hashrate): 0;
$m = $n->hashrate ? bitcoinvaluetoa($n->earnings * 24 * $algo_unit_factor * 1000000/$n->hashrate): 0;
if($i) echo ',';
$d = date('Y-m-d H:i:s', $n->time);

View file

@ -6,6 +6,8 @@ $s = 4*60*60;
$t = time() - 7*24*60*60;
$stats = getdbolist('db_hashstats', "time>$t and algo=:algo", array(':algo'=>$algo));
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
$res = array();
$first = 0;
foreach($stats as $n)
@ -19,16 +21,13 @@ foreach($stats as $n)
$res[$i] += $n->hashrate/4;
}
echo '[';
$data = array();
foreach($res as $i=>$n)
{
$m = round($n/1000000, 3);
if($i != $first) echo ',';
$m = round($n/(1000000*$algo_unit_factor), 3);
$d = date('Y-m-d H:i:s', $i);
echo "[\"$d\",$m]";
$data[] = array($d, $m);
}
echo ']';
echo json_encode($data);

View file

@ -6,6 +6,8 @@ $s = 4*60*60;
$t = time() - 7*24*60*60;
$stats = getdbolist('db_hashstats', "time>$t and algo=:algo", array(':algo'=>$algo));
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
$res = array();
$first = 0;
foreach($stats as $n)
@ -28,7 +30,7 @@ echo '[';
foreach($res as $i=>$n)
{
$m = $n['hashrate']? bitcoinvaluetoa($n['earnings'] * 1000000 / $n['hashrate']): 0;
$m = $n['hashrate']? bitcoinvaluetoa($n['earnings'] * $algo_unit_factor * 1000000 / $n['hashrate']): 0;
if($i != $first) echo ',';
$d = date('Y-m-d H:i:s', $i);

View file

@ -6,6 +6,8 @@ $s = 24*60*60;
$t = time() - 60*24*60*60;
$stats = getdbolist('db_hashstats', "time>$t and algo=:algo", array(':algo'=>$algo));
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
$res = array();
$first = 0;
foreach($stats as $n)
@ -19,16 +21,13 @@ foreach($stats as $n)
$res[$i] += $n->hashrate/24;
}
echo '[';
$data = array();
foreach($res as $i=>$n)
{
$m = round($n/1000000, 3);
if($i != $first) echo ',';
$m = round($n/(1000000*$algo_unit_factor), 3);
$d = date('Y-m-d H:i:s', $i);
echo "[\"$d\",$m]";
$data[] = array($d, $m);
}
echo ']';
echo json_encode($data);

View file

@ -6,6 +6,8 @@ $s = 24*60*60;
$t = time() - 60*24*60*60;
$stats = getdbolist('db_hashstats', "time>$t and algo=:algo", array(':algo'=>$algo));
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
$res = array();
foreach($stats as $n)
{
@ -30,7 +32,7 @@ foreach($res as $i=>$n)
{
if(!$n['hashrate']) continue;
$m = bitcoinvaluetoa($n['earnings'] * 1000000 / $n['hashrate']);
$m = bitcoinvaluetoa($n['earnings'] * $algo_unit_factor * 1000000 / $n['hashrate']);
$d = date('Y-m-d H:i:s', $i);
if($started) echo ',';

View file

@ -1,5 +1,9 @@
<?php
$algo = user()->getState('yaamp-algo');
$algo_unit = 'Mh';
$algo_factor = yaamp_algo_mBTC_factor($algo);
if ($algo_factor == 1000) $algo_unit = 'Gh';
JavascriptFile("/extensions/jqplot/jquery.jqplot.js");
JavascriptFile("/extensions/jqplot/plugins/jqplot.dateAxisRenderer.js");
@ -7,19 +11,29 @@ JavascriptFile("/extensions/jqplot/plugins/jqplot.barRenderer.js");
JavascriptFile("/extensions/jqplot/plugins/jqplot.highlighter.js");
JavascriptFile('/yaamp/ui/js/auto_refresh.js');
$t1 = time() - 2*24*60*60;
$t2 = time() - 7*24*60*60;
$t3 = time() - 30*24*60*60;
$hour = 60 * 60;
$days = 24 * $hour;
$row1 = dborow("select avg(hashrate) as a, sum(earnings) as b from hashstats where time>$t1 and algo=:algo", array(':algo'=>$algo));
$row2 = dborow("select avg(hashrate) as a, sum(earnings) as b from hashstats where time>$t2 and algo=:algo", array(':algo'=>$algo));
$row3 = dborow("select avg(hashrate) as a, sum(earnings) as b from hashstats where time>$t3 and algo=:algo", array(':algo'=>$algo));
$dbMax = (int) dboscalar("SELECT max(time-30*60) from hashstats WHERE time>:t AND algo=:algo", array(':t'=>time()-2*$hour,':algo'=>$algo));
$dtMax = max(time()-$hour, $dbMax);
$t1 = $dtMax - 2*$days;
$t2 = $dtMax - 7*$days;
$t3 = $dtMax - 30*$days;
$row1 = dborow("SELECT avg(hashrate) as a, sum(earnings) as b FROM hashstats WHERE time>=$t1 AND algo=:algo", array(':algo'=>$algo));
$row2 = dborow("SELECT avg(hashrate) as a, sum(earnings) as b FROM hashstats WHERE time>=$t2 AND algo=:algo", array(':algo'=>$algo));
$row3 = dborow("SELECT avg(hashrate) as a, sum(earnings) as b FROM hashstats WHERE time>=$t3 AND algo=:algo", array(':algo'=>$algo));
if($row1['a']>0 && $row2['a']>0 && $row3['a']>0)
{
$btcmhday1 = bitcoinvaluetoa($row1['b'] / $row1['a'] * 1000000 / 2);
$btcmhday2 = bitcoinvaluetoa($row2['b'] / $row2['a'] * 1000000 / 7);
$btcmhday3 = bitcoinvaluetoa($row3['b'] / $row3['a'] * 1000000 / 30);
$a1 = max(1., (double) $row1['a']);
$a2 = max(1., (double) $row2['a']);
$a3 = max(1., (double) $row3['a']);
$btcmhday1 = bitcoinvaluetoa(($row1['b'] / 2) * $algo_factor * (1000000 / $a1));
$btcmhday2 = bitcoinvaluetoa(($row2['b'] / 7) * $algo_factor * (1000000 / $a2));
$btcmhday3 = bitcoinvaluetoa(($row3['b'] / 30) * $algo_factor * (1000000 / $a3));
}
else
{
@ -54,6 +68,16 @@ foreach($algos as $a => $count)
$string .= "<option value='$a'>$a</option>";
}
// to fill the graphs on right edges (big tick interval of 4 days)
$dtMin1 = $t1 + $hour;
$dtMax1 = $dtMax;
$dtMin2 = $t2 - 2*$hour;
$dtMax2 = $dtMin2 + 7 * $days;
$dtMin3 = $dtMax1 - (8*4+1)*$days;
$dtMax3 = $dtMin3 + (8*4) * $days;
echo <<<end
<div id='resume_update_button' style='color: #444; background-color: #ffd; border: 1px solid #eea;
@ -84,7 +108,7 @@ $('#algo_select').change(function(event)
<ul>
<li>Average Hashrate: <b>{$hashrate1}h/s</b></li>
<li>BTC Value: <b>$total1</b></li>
<li>BTC/Mh/d: <b>$btcmhday1</b></li>
<li>BTC/{$algo_unit}/d: <b>$btcmhday1</b></li>
</ul>
<br>
@ -105,7 +129,7 @@ $('#algo_select').change(function(event)
<ul>
<li>Average Hashrate: <b>{$hashrate2}h/s</b></li>
<li>BTC Value: <b>$total2</b></li>
<li>BTC/Mh/d: <b>$btcmhday2</b></li>
<li>BTC/{$algo_unit}/d: <b>$btcmhday2</b></li>
</ul>
<br>
@ -120,13 +144,13 @@ $('#algo_select').change(function(event)
<td valign=top width=33%>
<div class="main-left-box">
<div class="main-left-title">Last 60 Days</div>
<div class="main-left-title">Last 30 Days</div>
<div class="main-left-inner">
<ul>
<li>Average Hashrate: <b>{$hashrate3}h/s</b></li>
<li>BTC Value: <b>$total3</b></li>
<li>BTC/Mh/d: <b>$btcmhday3</b></li>
<li>BTC/{$algo_unit}/d: <b>$btcmhday3</b></li>
</ul>
<br>
@ -143,7 +167,16 @@ $('#algo_select').change(function(event)
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<script>
<script type="text/javascript">
var dtMin1 = new Date(1000*{$dtMin1});
var dtMax1 = new Date(1000*{$dtMax1});
var dtMin2 = new Date(1000*{$dtMin2});
var dtMax2 = new Date(1000*{$dtMax2});
var dtMin3 = new Date(1000*{$dtMin3});
var dtMax3 = new Date(1000*{$dtMax3});
function page_refresh()
{
@ -187,26 +220,30 @@ function graph_init_1(data)
var t = $.parseJSON(data);
var plot1 = $.jqplot('graph_results_1', [t],
{
title: '<b>Hashrate (Mh/s)</b>',
title: '<b>Hashrate ({$algo_unit}/s)</b>',
axes: {
xaxis: {
min: dtMin1,
max: dtMax1,
tickInterval: 14400,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%#Hh</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.3f</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
}
},
seriesDefaults:
{
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
seriesDefaults: {
markerOptions: { style: 'none' },
rendererOptions: { smooth: true }
},
grid:
{
seriesColors: [ "rgba(78, 180, 180, 0.8)" ],
series: [ { fill: true } ],
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -225,23 +262,24 @@ function graph_init_2(data)
title: '<b>BTC/Day</b>',
axes: {
xaxis: {
min: dtMin1,
max: dtMax1,
tickInterval: 14400,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%#Hh</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.8f &nbsp;</font>'}
}
},
seriesDefaults:
{
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
},
grid:
{
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -257,26 +295,27 @@ function graph_init_3(data)
var t = $.parseJSON(data);
var plot1 = $.jqplot('graph_results_3', [t],
{
title: '<b>BTC/Mh/d</b>',
title: '<b>BTC/{$algo_unit}/d</b>',
axes: {
xaxis: {
min: dtMin1,
max: dtMax1,
tickInterval: 14400,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%#Hh</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.8f &nbsp;</font>'}
}
},
seriesDefaults:
{
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
rendererOptions: { barWidth: 3 }
},
grid:
{
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -294,26 +333,30 @@ function graph_init_4(data)
var t = $.parseJSON(data);
var plot1 = $.jqplot('graph_results_4', [t],
{
title: '<b>Hashrate (Mh/s)</b>',
title: '<b>Hashrate ({$algo_unit}/s)</b>',
axes: {
xaxis: {
min: dtMin2,
max: dtMax2,
tickInterval: 86400,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%d</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.3f</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
}
},
seriesDefaults:
{
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
seriesDefaults: {
markerOptions: { style: 'none' },
rendererOptions: { smooth: true }
},
grid:
{
seriesColors: [ "rgba(78, 180, 180, 0.8)" ],
series: [ { fill: true } ],
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -332,23 +375,24 @@ function graph_init_5(data)
title: '<b>BTC/Day</b>',
axes: {
xaxis: {
min: dtMin2,
max: dtMax2,
tickInterval: 86400,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%d</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.8f &nbsp;</font>'}
}
},
seriesDefaults:
{
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
rendererOptions: { barWidth: 3 }
},
grid:
{
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -364,26 +408,27 @@ function graph_init_6(data)
var t = $.parseJSON(data);
var plot1 = $.jqplot('graph_results_6', [t],
{
title: '<b>BTC/Mh/d</b>',
title: '<b>BTC/{$algo_unit}/d</b>',
axes: {
xaxis: {
min: dtMin2,
max: dtMax2,
tickInterval: 86400,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%d</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.8f &nbsp;</font>'}
}
},
seriesDefaults:
{
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
rendererOptions: { barWidth: 3 }
},
grid:
{
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -401,26 +446,30 @@ function graph_init_7(data)
var t = $.parseJSON(data);
var plot1 = $.jqplot('graph_results_7', [t],
{
title: '<b>Hashrate (Mh/s)</b>',
title: '<b>Hashrate ({$algo_unit}/s)</b>',
axes: {
xaxis: {
tickInterval: 604800,
min: dtMin3,
max: dtMax3,
tickInterval: 4 * 24*60*60,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%m/%d</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.3f</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
}
},
seriesDefaults:
{
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
seriesDefaults: {
markerOptions: { style: 'none' },
rendererOptions: { smooth: true }
},
grid:
{
seriesColors: [ "rgba(78, 180, 180, 0.8)" ],
series: [ { fill: true } ],
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -439,23 +488,24 @@ function graph_init_8(data)
title: '<b>BTC/Day</b>',
axes: {
xaxis: {
tickInterval: 604800,
min: dtMin3,
max: dtMax3,
tickInterval: 4 * 24*60*60,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%m/%d</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.8f &nbsp;</font>'}
}
},
seriesDefaults:
{
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
seriesDefaults: {
markerOptions: { style: 'none' },
rendererOptions: { smooth: true }
},
grid:
{
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2
@ -471,26 +521,27 @@ function graph_init_9(data)
var t = $.parseJSON(data);
var plot1 = $.jqplot('graph_results_9', [t],
{
title: '<b>BTC/Mh/d</b>',
title: '<b>BTC/{$algo_unit}/d</b>',
axes: {
xaxis: {
tickInterval: 604800,
min: dtMin3,
max: dtMax3,
tickInterval: 4 * 24*60*60,
renderer: $.jqplot.DateAxisRenderer,
tickOptions: {formatString: '<font size=1>%m/%d</font>'}
},
yaxis: {
min: 0.0,
tickOptions: {formatString: '<font size=1>%#.8f &nbsp;</font>'}
}
},
seriesDefaults:
{
renderer: $.jqplot.BarRenderer,
rendererOptions: {barWidth: 3}
seriesDefaults: {
markerOptions: { style: 'none' },
rendererOptions: { smooth: true }
},
grid:
{
grid: {
borderWidth: 1,
shadowWidth: 2,
shadowDepth: 2