From bc3f78a7144a533da822a2a45113b835be9c48e3 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Wed, 27 May 2015 16:37:41 +0200 Subject: [PATCH] Bugfix duration of job shows only seconds Fixes #471: MantisBT Subject --- .../src/Application/View/Helper/JobDuration.php | 8 ++++---- module/Job/src/Job/Model/JobTable.php | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/module/Application/src/Application/View/Helper/JobDuration.php b/module/Application/src/Application/View/Helper/JobDuration.php index ffb8d961..89459df3 100644 --- a/module/Application/src/Application/View/Helper/JobDuration.php +++ b/module/Application/src/Application/View/Helper/JobDuration.php @@ -3,7 +3,7 @@ /** * * bareos-webui - Bareos Web-Frontend - * + * * @link https://github.com/bareos/bareos-webui for the canonical source repository * @copyright Copyright (c) 2013-2014 Bareos GmbH & Co. KG (http://www.bareos.org/) * @license GNU Affero General Public License (http://www.gnu.org/licenses/) @@ -22,15 +22,15 @@ * along with this program. If not, see . * */ - + namespace Application\View\Helper; use Zend\View\Helper\AbstractHelper; -class JobDuration extends AbstractHelper +class JobDuration extends AbstractHelper { public function __invoke($duration) { - return sprintf('%02d:%02d:%02d', ($duration/3600),($duration/60%60), $duration%60); + return $duration; } } diff --git a/module/Job/src/Job/Model/JobTable.php b/module/Job/src/Job/Model/JobTable.php index 6853d820..dddb656f 100644 --- a/module/Job/src/Job/Model/JobTable.php +++ b/module/Job/src/Job/Model/JobTable.php @@ -61,10 +61,11 @@ public function getDbDriverConfig() { public function fetchAll($paginated=false, $order_by=null, $order=null) { if($this->getDbDriverConfig() == "Pdo_Mysql" || $this->getDbDriverConfig() == "Mysqli") { - $duration = new Expression("TIMESTAMPDIFF(SECOND, StartTime, EndTime)"); + $duration = new Expression("TIMEDIFF(EndTime, StartTime)"); } elseif($this->getDbDriverConfig() == "Pdo_Pgsql" || $this->getDbDriverConfig() == "Pgsql") { - $duration = new Expression("DATE_PART('second', endtime::timestamp - starttime::timestamp)"); + //$duration = new Expression("DATE_PART('hour', endtime::timestamp - starttime::timestamp)"); + $duration = new Expression("endtime::timestamp - starttime::timestamp"); } $bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig()); @@ -251,11 +252,11 @@ public function getWaitingJobs($paginated=false, $order_by=null, $order=null) public function getLast24HoursSuccessfulJobs($paginated=false, $order_by=null, $order=null) { if($this->getDbDriverConfig() == "Pdo_Mysql" || $this->getDbDriverConfig() == "Mysqli") { - $duration = new Expression("TIMESTAMPDIFF(SECOND, StartTime, EndTime)"); + $duration = new Expression("TIMEDIFF(EndTime, StartTime)"); $interval = "now() - interval 1 day"; } elseif($this->getDbDriverConfig() == "Pdo_Pgsql" || $this->getDbDriverConfig() == "Pgsql") { - $duration = new Expression("DATE_PART('second', endtime::timestamp - starttime::timestamp)"); + $duration = new Expression("endtime::timestamp - starttime::timestamp"); $interval = "now() - interval '1 day'"; } @@ -316,11 +317,11 @@ public function getLast24HoursSuccessfulJobs($paginated=false, $order_by=null, $ public function getLast24HoursUnsuccessfulJobs($paginated=false, $order_by=null, $order=null) { if($this->getDbDriverConfig() == "Pdo_Mysql" || $this->getDbDriverConfig() == "Mysqli") { - $duration = new Expression("TIMESTAMPDIFF(SECOND, StartTime, EndTime)"); + $duration = new Expression("TIMEDIFF(EndTime, StartTime)"); $interval = "now() - interval 1 day"; } elseif($this->getDbDriverConfig() == "Pdo_Pgsql" || $this->getDbDriverConfig() == "Pgsql") { - $duration = new Expression("DATE_PART('second', endtime::timestamp - starttime::timestamp)"); + $duration = new Expression("endtime::timestamp - starttime::timestamp"); $interval = "now() - interval '1 day'"; }