api: add current workers count

This commit is contained in:
Tanguy Pruvot 2015-07-05 12:33:26 +02:00
parent 7a0112c6a9
commit d4f6f99f95
2 changed files with 11 additions and 5 deletions

View file

@ -17,9 +17,14 @@ class ApiController extends CommonController
{ {
if($i) echo ", "; if($i) echo ", ";
$coins = controller()->memcache->get_database_count_ex("api_status_coins-$algo", $coins = (int) controller()->memcache->get_database_count_ex("api_status_coins-$algo",
'db_coins', "enable and visible and auto_ready and algo=:algo", array(':algo'=>$algo)); 'db_coins', "enable and visible and auto_ready and algo=:algo", array(':algo'=>$algo));
$workers = (int) controller()->memcache->get_database_scalar("api_status_workers-$algo",
"select COUNT(id) FROM workers WHERE algo=:algo",
array(':algo'=>$algo)
);
$hashrate = controller()->memcache->get_database_scalar("api_status_hashrate-$algo", $hashrate = controller()->memcache->get_database_scalar("api_status_hashrate-$algo",
"select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo)); "select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo));
@ -28,7 +33,7 @@ class ApiController extends CommonController
$price = bitcoinvaluetoa(take_yaamp_fee($price/1000, $algo)); $price = bitcoinvaluetoa(take_yaamp_fee($price/1000, $algo));
$rental = controller()->memcache->get_database_scalar("api_status_price-$algo", $rental = controller()->memcache->get_database_scalar("api_status_rental-$algo",
"select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo)); "select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo));
$rental = bitcoinvaluetoa($rental); $rental = bitcoinvaluetoa($rental);
@ -63,6 +68,7 @@ class ApiController extends CommonController
echo "\"coins\": $coins, "; echo "\"coins\": $coins, ";
echo "\"fees\": $fees, "; echo "\"fees\": $fees, ";
echo "\"hashrate\": $hashrate, "; echo "\"hashrate\": $hashrate, ";
echo "\"workers\": $workers, ";
echo "\"estimate_current\": $price, "; echo "\"estimate_current\": $price, ";
echo "\"estimate_last24h\": $avgprice, "; echo "\"estimate_last24h\": $avgprice, ";
echo "\"actual_last24h\": $btcmhday1, "; echo "\"actual_last24h\": $btcmhday1, ";

View file

@ -63,7 +63,7 @@ foreach($algos as $item)
$algo = $item[1]; $algo = $item[1];
$coins = getdbocount('db_coins', "enable and visible and auto_ready and algo=:algo", array(':algo'=>$algo)); $coins = getdbocount('db_coins', "enable and visible and auto_ready and algo=:algo", array(':algo'=>$algo));
$count = getdbocount('db_workers', "algo=:algo", array(':algo'=>$algo)); $workers = getdbocount('db_workers', "algo=:algo", array(':algo'=>$algo));
$hashrate = controller()->memcache->get_database_scalar("current_hashrate-$algo", $hashrate = controller()->memcache->get_database_scalar("current_hashrate-$algo",
"select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo)); "select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo));
@ -104,7 +104,7 @@ foreach($algos as $item)
echo "<td><b>$algo</b></td>"; echo "<td><b>$algo</b></td>";
echo "<td align=right style='font-size: .8em;'>$port</td>"; echo "<td align=right style='font-size: .8em;'>$port</td>";
echo "<td align=right style='font-size: .8em;'>$coins</td>"; echo "<td align=right style='font-size: .8em;'>$coins</td>";
echo "<td align=right style='font-size: .8em;'>$count</td>"; echo "<td align=right style='font-size: .8em;'>$workers</td>";
echo "<td align=right style='font-size: .8em;'>$hashrate</td>"; echo "<td align=right style='font-size: .8em;'>$hashrate</td>";
echo "<td align=right style='font-size: .8em;'>{$fees}%</td>"; echo "<td align=right style='font-size: .8em;'>{$fees}%</td>";
@ -120,7 +120,7 @@ foreach($algos as $item)
echo "</tr>"; echo "</tr>";
$total_coins += $coins; $total_coins += $coins;
$total_miners += $count; $total_miners += $workers;
} }
echo "</tbody>"; echo "</tbody>";