]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New function CoutLastJobs in bweb.inc.php
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 20 Dec 2010 16:26:53 +0000 (17:26 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:43:33 +0000 (14:43 +0200)
 - Removed GetLastJobs() from bweb.inc.php
 - Removed GetLastErrorJobs() from bweb.inc.php

gui/bacula-web/bweb.inc.php

index e85efe96bac207051ab50650108619d56d35a2cb..74c9ec48de18456f4fb5487a5bb5735446837b50 100644 (file)
@@ -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<br />" . $status->getMessage() );
+                               die( "Unable to get last $status jobs number from catalog <br />" . $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 <br />";
-                       //echo "end date: $end_date <br />";
-                       
-                       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<br />query = $query <br />" . $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()