From 4fe9d325b23fa4c0a043021f758b2ef4e67dcacc Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Mon, 20 Dec 2010 17:26:53 +0100 Subject: [PATCH] bacula-web: New function CoutLastJobs in bweb.inc.php - Removed GetLastJobs() from bweb.inc.php - Removed GetLastErrorJobs() from bweb.inc.php --- gui/bacula-web/bweb.inc.php | 71 +++++++++++-------------------------- 1 file changed, 20 insertions(+), 51 deletions(-) diff --git a/gui/bacula-web/bweb.inc.php b/gui/bacula-web/bweb.inc.php index e85efe96ba..74c9ec48de 100644 --- a/gui/bacula-web/bweb.inc.php +++ b/gui/bacula-web/bweb.inc.php @@ -349,69 +349,38 @@ class Bweb extends DB { return $volumes; } // end function GetVolumeList() - public function GetLastJobs( $delay = LAST_DAY ) + public function CountLastJobs( $delay = LAST_DAY, $status ) { - $query = ""; - $start_date = ""; - $end_date = ""; + $query = "SELECT COUNT(JobId) AS job_nb FROM Job "; - // Interval calculation - $end_date = mktime(); - $start_date = $end_date - $delay; + // Interval condition for SQL query + $end_date = mktime(); + $start_date = $end_date - $delay; - $start_date = date( "Y-m-d H:i:s", $start_date ); - $end_date = date( "Y-m-d H:i:s", $end_date ); + $start_date = date( "Y-m-d H:i:s", $start_date ); + $end_date = date( "Y-m-d H:i:s", $end_date ); - switch( $this->driver ) + $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date' "; + + // Job Status for SQL query + switch( $status ) { - case 'mysql': - $query = 'SELECT COUNT(JobId) AS completed_jobs '; - $query .= 'FROM Job '; - $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date' "; - $query .= "AND JobStatus = 'T'"; + case 'completed': + $query .= "AND JobStatus = 'T' "; break; - } - + case 'failed': + $query .= "AND JobStatus = 'f' "; + break; + } // end switch + $jobs = $this->db_link->query( $query ); if (PEAR::isError( $jobs ) ) { - die( "Unable to get last completed jobs status from catalog
" . $status->getMessage() ); + die( "Unable to get last $status jobs number from catalog
" . $status->getMessage() ); }else { return $jobs->fetchRow( DB_FETCHMODE_ASSOC ); } - } // end function GetLastJobStatus() - - public function GetLastErrorJobs( $delay = LAST_DAY ) - { - $query = ""; - - // Interval calculation - $end_date = mktime(); - $start_date = $end_date - $delay; - - $start_date = date( "Y-m-d H:i:s", $start_date ); - $end_date = date( "Y-m-d H:i:s", $end_date ); - - //echo "start date: $start_date
"; - //echo "end date: $end_date
"; - - switch( $this->driver ) - { - default: - $query = 'SELECT COUNT(JobId) AS failed_jobs '; - $query .= 'FROM Job '; - $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date' "; - $query .= "AND JobStatus = 'f'"; - break; - } - $result = $this->db_link->query( $query ); - - if (PEAR::isError( $result ) ) { - die( "Unable to get last failed jobs status from catalog
query = $query
" . $result->getMessage() ); - }else { - return $result->fetchRow( DB_FETCHMODE_ASSOC ); - } // end if else - } // end function GetLastErrorJobs + } // Return the list of Pools in a array public function Get_Pools_List() -- 2.39.5