From: Davide Franco Date: Mon, 27 Jun 2011 14:47:06 +0000 (+0200) Subject: bacula-web: Fixed bug with Volumes by Pool in main dashboard X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a5907f417b1bdff8093ac0d9b0f7b548f75d84d2;p=bacula%2Fbacula bacula-web: Fixed bug with Volumes by Pool in main dashboard - Fixed pgsql sql query - Changed some variables name --- diff --git a/gui/bacula-web/includes/bweb.inc.php b/gui/bacula-web/includes/bweb.inc.php index 992b175faf..a7fc2cfd4c 100644 --- a/gui/bacula-web/includes/bweb.inc.php +++ b/gui/bacula-web/includes/bweb.inc.php @@ -442,18 +442,35 @@ class Bweb extends DB public function CountVolumesByPool( $pool_id ) { - var_dump( $pool_id ); $res = null; $nb_vol = null; - $query = "SELECT COUNT(*) as nb_vol FROM media WHERE poolid = $pool_id"; + $query = ''; + + switch( $this->driver ) + { + case 'sqlite': + case 'mysql': + $query = 'SELECT COUNT(*) as vols,Pool.name as pool_name '; + $query .= 'FROM Media '; + $query .= 'LEFT JOIN Pool ON (Media.PoolId = Pool.PoolId) '; + $query .= 'WHERE Media.poolid = ' . $pool_id; + break; + case 'pgsql': + $query = 'SELECT COUNT(*) as vols,Pool.name as pool_name '; + $query .= 'FROM Media '; + $query .= 'LEFT OUTER JOIN Pool ON (Media.PoolId = Pool.PoolId) '; + $query .= 'WHERE Media.poolid = ' . $pool_id; + $query .= 'GROUP BY pool.name'; + break; + } $res = $this->db_link->query( $query ); if( PEAR::isError( $res ) ) $this->triggerDBError( 'Unable to get volume number from pool', $res ); else - $nb_vol = $res->fetchRow( ); + $vols = $res->fetchRow( ); - return array( $pool_name, $nb_vol['nb_vol'] ); + return array( $vols['pool_name'], $vols['vols'] ); } public function GetStoredFiles( $delay = LAST_DAY ) diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 795e36347d..88e6e46ba1 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -81,8 +81,9 @@ $data = array(); $graph = new BGraph( "graph1.png" ); $pools = $dbSql->Get_Pools_List(); -while( $pool = $pools->fetchRow( ) ) - array_push( $data, $pool ); +while( $pool = $pools->fetchRow( ) ) { + array_push( $data, $dbSql->CountVolumesByPool( $pool['poolid']) ); +} $graph->SetData( $data, 'pie', 'text-data-single' ); $graph->SetGraphSize( 400, 230 );