]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Improve job statuses for job overview purpose
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 23 Jan 2023 09:41:21 +0000 (10:41 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 5 Mar 2023 06:06:30 +0000 (07:06 +0100)
gui/baculum/protected/API/Modules/JobManager.php

index 0a13a0bd1f0073735b01ff320f1afcd81daa7022..b41183662956edc9e2f6be1293000e6f337e102a 100644 (file)
@@ -63,18 +63,19 @@ LEFT JOIN FileSet USING (FilesetId)'
 
                $result = JobRecord::finder()->findAllBySql($sql, $where['params']);
                if ($overview) {
-                       $misc = $this->getModule('misc');
-                       $st_ok = array_keys($misc->getJobStatesByType('ok'));
-                       $st_warn = array_keys($misc->getJobStatesByType('warning'));
-                       $st_err = array_keys($misc->getJobStatesByType('error'));
-                       $st_can = array_keys($misc->getJobStatesByType('cancel'));
-                       $st_run = array_keys($misc->getJobStatesByType('running'));
-                       $successful = array_merge($st_ok, $st_warn);
-                       $unsuccessful = array_merge($st_err, $st_can);
-                       $running = $st_run;
+                       /**
+                        * Job statuses in some parts are not compatible with rest of the API.
+                        * NOTE: Used here are also internal job statuses that are not used in the Catalog
+                        * but they are used internally by Bacula.
+                        */
+                       $successful = ['T'];
+                       $unsuccessful = ['A', 'E', 'f'];
+                       $warning = ['I', 'e'];
+                       $running = ['C', 'B', 'D', 'F', 'L', 'M', 'R', 'S', 'a', 'c', 'd', 'i', 'j', 'l', 'm', 'p', 'q', 's', 't'];
                        $sql = 'SELECT
-                               (SELECT COUNT(1) FROM Job ' . $where['where'] . ' AND Job.JobStatus IN (\'' . implode('\',\'', $successful) . '\')) AS successful,
+                               (SELECT COUNT(1) FROM Job ' . $where['where'] . ' AND Job.JobStatus IN (\'' . implode('\',\'', $successful) . '\') AND Job.JobErrors = 0) AS successful,
                                (SELECT COUNT(1) FROM Job ' . $where['where'] . ' AND Job.JobStatus IN (\'' . implode('\',\'', $unsuccessful) . '\')) AS unsuccessful,
+                               (SELECT COUNT(1) FROM Job ' . $where['where'] . ' AND (Job.JobStatus IN (\'' . implode('\',\'', $warning) . '\') OR (Job.JobStatus IN (\'' . implode('\',\'', $successful) . '\') AND JobErrors > 0))) AS warning,
                                (SELECT COUNT(1) FROM Job ' . $where['where'] . ' AND Job.JobStatus IN (\'' . implode('\',\'', $running) . '\')) AS running,
                                (SELECT COUNT(1) FROM Job ' . $where['where'] . ') AS all
                        ';