From d4f6f99f9586ce23bedd0bf3afbde3ac9b7109c1 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 5 Jul 2015 12:33:26 +0200 Subject: [PATCH] api: add current workers count --- web/yaamp/modules/api/ApiController.php | 10 ++++++++-- web/yaamp/modules/site/results/current_results.php | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/web/yaamp/modules/api/ApiController.php b/web/yaamp/modules/api/ApiController.php index 8f755c1..f465f90 100644 --- a/web/yaamp/modules/api/ApiController.php +++ b/web/yaamp/modules/api/ApiController.php @@ -17,9 +17,14 @@ class ApiController extends CommonController { 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)); + $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", "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)); - $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)); $rental = bitcoinvaluetoa($rental); @@ -63,6 +68,7 @@ class ApiController extends CommonController echo "\"coins\": $coins, "; echo "\"fees\": $fees, "; echo "\"hashrate\": $hashrate, "; + echo "\"workers\": $workers, "; echo "\"estimate_current\": $price, "; echo "\"estimate_last24h\": $avgprice, "; echo "\"actual_last24h\": $btcmhday1, "; diff --git a/web/yaamp/modules/site/results/current_results.php b/web/yaamp/modules/site/results/current_results.php index e8ca3a0..7aaaa54 100644 --- a/web/yaamp/modules/site/results/current_results.php +++ b/web/yaamp/modules/site/results/current_results.php @@ -63,7 +63,7 @@ foreach($algos as $item) $algo = $item[1]; $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", "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 "$algo"; echo "$port"; echo "$coins"; - echo "$count"; + echo "$workers"; echo "$hashrate"; echo "{$fees}%"; @@ -120,7 +120,7 @@ foreach($algos as $item) echo ""; $total_coins += $coins; - $total_miners += $count; + $total_miners += $workers; } echo "";