Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Bugfix duration of job shows only seconds
Browse files Browse the repository at this point in the history
Fixes #471: MantisBT Subject
  • Loading branch information
fbergkemper committed May 27, 2015
1 parent 55af515 commit bc3f78a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Expand Up @@ -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/)
Expand All @@ -22,15 +22,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

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;
}
}
13 changes: 7 additions & 6 deletions module/Job/src/Job/Model/JobTable.php
Expand Up @@ -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());
Expand Down Expand Up @@ -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'";
}

Expand Down Expand Up @@ -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'";
}

Expand Down

0 comments on commit bc3f78a

Please sign in to comment.