pool/web/yaamp/modules/renting/graph_price_results.php
Tanguy Pruvot bb31cec957 dos2unix all files, we are on linux
trim them, btw... its important to start on a clean base...
2015-07-12 04:40:50 +02:00

54 lines
781 B
PHP

<?php
$percent = 16;
$algo = user()->getState('yaamp-algo');
$step = 15*60;
$t = time() - 24*60*60;
$stats = getdbolist('db_hashrate', "time>$t and algo=:algo order by time", array(':algo'=>$algo));
$averages = array();
echo '[[';
for($i = 0; $i < 95-count($stats); $i++)
{
$d = date('Y-m-d H:i:s', $t);
echo "[\"$d\",0],";
$t += $step;
$averages[] = array($d, 0);
}
foreach($stats as $i=>$n)
{
$m = $n->rent;
if($m == null) $m=0;
if($i) echo ',';
$d = date('Y-m-d H:i:s', $n->time);
echo "[\"$d\",$m]";
$averages[] = array($d, $m);
}
echo '],[';
$average = $averages[0][1];
foreach($averages as $i=>$n)
{
if($i) echo ',';
$average = ($average*(100-$percent) + $n[1]*$percent) / 100;
$m = round($average, 5);
echo "[\"{$n[0]}\",$m]";
}
echo ']]';