Skip to content
Permalink
Browse files

Fix server databases statistics

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed Jun 25, 2018
1 parent 2cea709 commit 05cff7ed58ff1ef930aa2c6e0d3ef162ec1f6154
Showing with 8 additions and 5 deletions.
  1. +8 −5 libraries/classes/Controllers/Server/ServerDatabasesController.php
@@ -270,14 +270,17 @@ private function _getHtmlForDatabases(array $replication_types)
$first_database = reset($this->_databases);
// table col order
$column_order = $this->_getColumnOrder();
$dbColumnOrders = [];
// calculate aggregate stats to display in footer
foreach ($this->_databases as $current) {
$dbColumnOrders[$current['SCHEMA_NAME']] = $this->_getColumnOrder();
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $current)
&& is_numeric($stat['footer'])
) {
$column_order[$stat_name]['footer'] += $current[$stat_name];
$dbColumnOrders[$current['SCHEMA_NAME']][$stat_name]['footer'] = $current[$stat_name];
}
}
}
@@ -287,7 +290,7 @@ private function _getHtmlForDatabases(array $replication_types)
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $first_database)) {
if ($stat['format'] == 'byte') {
$byte_format = Util_formatByteDown($stat['footer'], 3, 1);
$byte_format = Util::formatByteDown($stat['footer'], 3, 1);
$values[$stat_name] = $byte_format[0];
$units[$stat_name] = $byte_format[1];
} elseif ($stat['format'] == 'number') {
@@ -320,7 +323,7 @@ private function _getHtmlForDatabases(array $replication_types)
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
]);
$html .= $this->_getHtmlForTableBody($column_order, $replication_types);
$html .= $this->_getHtmlForTableBody($dbColumnOrders, $replication_types);
$html .= $this->template->render('server/databases/databases_footer', [
'column_order' => $column_order,
@@ -396,7 +399,7 @@ private function _getColumnOrder()
*
* @return string
*/
private function _getHtmlForTableBody(array $column_order, array $replication_types)
private function _getHtmlForTableBody(array $dbColumnOrders, array $replication_types)
{
$html = '<tbody>' . "\n";
@@ -408,7 +411,7 @@ private function _getHtmlForTableBody(array $column_order, array $replication_ty
$generated_html = $this->_buildHtmlForDb(
$current,
$column_order,
$dbColumnOrders[$current['SCHEMA_NAME']],
$replication_types,
$GLOBALS['replication_info'],
$tr_class
@@ -486,7 +489,7 @@ public function _buildHtmlForDb(
$values[$stat_name] = $byte_format[0];
$units[$stat_name] = $byte_format[1];
} elseif ($stat['format'] == 'number') {
$values[$stat_name] = Util_formatNumber($stat['footer'], 0);
$values[$stat_name] = Util::formatNumber($stat['footer'], 0);
} else {
$values[$stat_name] = htmlentities($stat['footer'], 0);
}

0 comments on commit 05cff7e

Please sign in to comment.
You can’t perform that action at this time.