[IMPROVED]
Splitting dashboard calls up instead of using one single API call: * Use getuserbalance for Balance updates * Use getuserworkers for Worker updates For those and potential other SQL intensive Ajax calls I have added a long ajax refresh interval setting. It can be set via admin panel and will change the refresh time on the JS file on the dashboard for those two calls. Should help a bit with high worker and transaction volume pools. Address #1159
This commit is contained in:
parent
b2ac77d9a5
commit
8e4c56d597
@ -104,6 +104,13 @@ $aSettings['statistics'][] = array(
|
||||
'name' => 'statistics_ajax_refresh_interval', 'value' => $setting->getValue('statistics_ajax_refresh_interval'),
|
||||
'tooltip' => 'How often to refresh data via ajax in seconds.'
|
||||
);
|
||||
$aSettings['statistics'][] = array(
|
||||
'display' => 'Ajax Long Refresh Interval', 'type' => 'select',
|
||||
'options' => array('5' => '5', '10' => '10', '15' => '15', '30' => '30', '60' => '60', '600' => '600', '1800' => '1800', '3600' => '3600' ),
|
||||
'default' => 10,
|
||||
'name' => 'statistics_ajax_long_refresh_interval', 'value' => $setting->getValue('statistics_ajax_long_refresh_interval'),
|
||||
'tooltip' => 'How often to refresh data via ajax in seconds. User for SQL costly queries like getBalance and getWorkers.'
|
||||
);
|
||||
$aSettings['statistics'][] = array(
|
||||
'display' => 'Ajax Data Interval', 'type' => 'select',
|
||||
'options' => array('60' => '1', '180' => '3', '300' => '5', '600' => '10'),
|
||||
|
||||
@ -75,9 +75,6 @@ $dPersonalHashrateAdjusted = $dPersonalHashrate * $dPersonalHashrateModifier;
|
||||
$dPoolHashrateAdjusted = $dPoolHashrate * $dPoolHashrateModifier;
|
||||
$dNetworkHashrateAdjusted = $dNetworkHashrate / 1000 * $dNetworkHashrateModifier;
|
||||
|
||||
// Worker information
|
||||
$aWorkers = $worker->getWorkers($user_id, $interval);
|
||||
|
||||
// Coin price
|
||||
$aPrice = $setting->getValue('price');
|
||||
|
||||
@ -99,7 +96,7 @@ $data = array(
|
||||
'personal' => array (
|
||||
'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'sharedifficulty' => $dPersonalShareDifficulty,
|
||||
'shares' => array('valid' => $aUserRoundShares['valid'], 'invalid' => $aUserRoundShares['invalid'], 'invalid_percent' => $dUserInvalidPercent, 'unpaid' => $dUnpaidShares ),
|
||||
'balance' => $transaction->getBalance($user_id), 'estimates' => $aEstimates, 'workers' => $aWorkers ),
|
||||
'estimates' => $aEstimates),
|
||||
'pool' => array(
|
||||
'info' => array(
|
||||
'name' => $setting->getValue('website_name'),
|
||||
|
||||
@ -46,6 +46,7 @@ if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActi
|
||||
|
||||
// Some settings to propagate to template
|
||||
if (! $statistics_ajax_refresh_interval = $setting->getValue('statistics_ajax_refresh_interval')) $statistics_ajax_refresh_interval = 10;
|
||||
if (! $statistics_ajax_long_refresh_interval = $setting->getValue('statistics_ajax_long_refresh_interval')) $statistics_ajax_long_refresh_interval = 10;
|
||||
|
||||
// Small helper array
|
||||
$aHashunits = array( '1' => 'KH/s', '0.001' => 'MH/s', '0.000001' => 'GH/s' );
|
||||
@ -76,6 +77,7 @@ $aGlobal = array(
|
||||
'disable_notifications' => $setting->getValue('disable_notifications'),
|
||||
'monitoring_uptimerobot_api_keys' => $setting->getValue('monitoring_uptimerobot_api_keys'),
|
||||
'statistics_ajax_refresh_interval' => $statistics_ajax_refresh_interval,
|
||||
'statistics_ajax_long_refresh_interval' => $statistics_ajax_long_refresh_interval,
|
||||
'price' => array( 'currency' => $config['price']['currency'] ),
|
||||
'targetdiff' => $config['difficulty'],
|
||||
'currency' => $config['currency'],
|
||||
|
||||
@ -17,7 +17,9 @@ $(document).ready(function(){
|
||||
var g1, g2, g3, g4, g5;
|
||||
|
||||
// Ajax API URL
|
||||
var url = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getdashboarddata&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
|
||||
var url_dashboard = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getdashboarddata&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
|
||||
var url_worker = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getuserworkers&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
|
||||
var url_balance = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getuserbalance&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
|
||||
|
||||
// Enable all included plugins
|
||||
// $.jqplot.config.enablePlugins = true;
|
||||
@ -128,9 +130,15 @@ $(document).ready(function(){
|
||||
if (typeof(plot2) != "undefined") plot2.replot(replotShareinfoOptions);
|
||||
}
|
||||
|
||||
// Refresh balance information
|
||||
function refreshBalanceData(data) {
|
||||
balance = data.getuserbalance.data
|
||||
$('#b-confirmed').html(balance.confirmed);
|
||||
$('#b-unconfirmed').html(balance.unconfirmed);
|
||||
}
|
||||
|
||||
// Refresh other static numbers on the template
|
||||
function refreshStaticData(data) {
|
||||
$('#b-confirmed').html(data.getdashboarddata.data.personal.balance.confirmed);
|
||||
$('#b-unconfirmed').html(data.getdashboarddata.data.personal.balance.unconfirmed);
|
||||
$('#b-price').html((parseFloat(data.getdashboarddata.data.pool.price).toFixed(8)));
|
||||
$('#b-dworkers').html(data.getdashboarddata.data.pool.workers);
|
||||
$('#b-hashrate').html((parseFloat(data.getdashboarddata.data.personal.hashrate).toFixed(2)));
|
||||
@ -165,8 +173,7 @@ $(document).ready(function(){
|
||||
|
||||
// Refresh worker information
|
||||
function refreshWorkerData(data) {
|
||||
data = data.getdashboarddata.data;
|
||||
workers = data.personal.workers;
|
||||
workers = data.getuserworkers.data;
|
||||
length = workers.length;
|
||||
$('#b-workers').html('');
|
||||
for (var i = j = 0; i < length; i++) {
|
||||
@ -179,17 +186,44 @@ $(document).ready(function(){
|
||||
}
|
||||
|
||||
// Our worker process to keep gauges and graph updated
|
||||
(function worker() {
|
||||
(function worker1() {
|
||||
$.ajax({
|
||||
url: url,
|
||||
url: url_dashboard,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
refreshInformation(data);
|
||||
refreshStaticData(data);
|
||||
},
|
||||
complete: function() {
|
||||
setTimeout(worker1, {/literal}{($GLOBAL.config.statistics_ajax_refresh_interval * 1000)|default:"10000"}{literal})
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
// Our worker process to keep worker information updated
|
||||
(function worker3() {
|
||||
$.ajax({
|
||||
url: url_balance,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
refreshBalanceData(data);
|
||||
},
|
||||
complete: function() {
|
||||
setTimeout(worker3, {/literal}{($GLOBAL.config.statistics_ajax_long_refresh_interval * 1000)|default:"10000"}{literal})
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
// Our worker process to keep gauges and graph updated
|
||||
(function worker2() {
|
||||
$.ajax({
|
||||
url: url_worker,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
refreshWorkerData(data);
|
||||
},
|
||||
complete: function() {
|
||||
setTimeout(worker, {/literal}{($GLOBAL.config.statistics_ajax_refresh_interval * 1000)|default:"10000"}{literal})
|
||||
setTimeout(worker2, {/literal}{($GLOBAL.config.statistics_ajax_long_refresh_interval * 1000)|default:"10000"}{literal})
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user