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

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
Fixes broken link in several places to view client details.
  • Loading branch information
fbergkemper committed Mar 10, 2015
1 parent b4650e8 commit 83f1077
Showing 1 changed file with 70 additions and 43 deletions.
113 changes: 70 additions & 43 deletions module/Job/src/Job/Model/JobTable.php
Expand Up @@ -5,7 +5,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/)
* @copyright Copyright (c) 2013-2015 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -78,6 +78,7 @@ public function fetchAll($paginated=false, $order_by=null, $order=null)
$bsqlch->strdbcompat("StartTime"),
$bsqlch->strdbcompat("EndTime"),
$bsqlch->strdbcompat("JobStatus"),
$bsqlch->strdbcompat("ClientId"),
'duration' => $duration,
)
);
Expand Down Expand Up @@ -140,9 +141,21 @@ public function getRunningJobs($paginated=false, $order_by=null, $order=null)
$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
$select = new Select();
$select->from($bsqlch->strdbcompat("Job"));
$select->columns(array(
$bsqlch->strdbcompat("JobId"),
$bsqlch->strdbcompat("Name"),
$bsqlch->strdbcompat("Type"),
$bsqlch->strdbcompat("Level"),
$bsqlch->strdbcompat("StartTime"),
$bsqlch->strdbcompat("EndTime"),
$bsqlch->strdbcompat("JobBytes"),
$bsqlch->strdbcompat("JobStatus"),
$bsqlch->strdbcompat("ClientId")
)
);
$select->join(
$bsqlch->strdbcompat("Client"),
$bsqlch->strdbcompat("Job.ClientId = Client.ClientId"),
$bsqlch->strdbcompat("Job.ClientId = Client.ClientId"),
array($bsqlch->strdbcompat("ClientName") => $bsqlch->strdbcompat("Name"))
);
$select->where(
Expand Down Expand Up @@ -179,6 +192,18 @@ public function getWaitingJobs($paginated=false, $order_by=null, $order=null)
$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
$select = new Select();
$select->from($bsqlch->strdbcompat("Job"));
$select->columns(array(
$bsqlch->strdbcompat("JobId"),
$bsqlch->strdbcompat("Name"),
$bsqlch->strdbcompat("Type"),
$bsqlch->strdbcompat("Level"),
$bsqlch->strdbcompat("StartTime"),
$bsqlch->strdbcompat("EndTime"),
$bsqlch->strdbcompat("JobBytes"),
$bsqlch->strdbcompat("JobStatus"),
$bsqlch->strdbcompat("ClientId")
)
);
$select->join(
$bsqlch->strdbcompat("Client"),
$bsqlch->strdbcompat("Job.ClientId = Client.ClientId"),
Expand Down Expand Up @@ -225,45 +250,46 @@ 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)");
if($this->getDbDriverConfig() == "Pdo_Mysql" || $this->getDbDriverConfig() == "Mysqli") {
$duration = new Expression("TIMESTAMPDIFF(SECOND, StartTime, EndTime)");
$interval = "now() - interval 1 day";
}
elseif($this->getDbDriverConfig() == "Pdo_Pgsql" || $this->getDbDriverConfig() == "Pgsql") {
elseif($this->getDbDriverConfig() == "Pdo_Pgsql" || $this->getDbDriverConfig() == "Pgsql") {
$duration = new Expression("DATE_PART('second', endtime::timestamp - starttime::timestamp)");
$interval = "now() - interval '1 day'";
}

$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
$select = new Select();
$select->from($bsqlch->strdbcompat("Job"));
$select->columns(array(
$bsqlch->strdbcompat("JobId"),
$bsqlch->strdbcompat("Name"),
$bsqlch->strdbcompat("Type"),
$bsqlch->strdbcompat("Type"),
$bsqlch->strdbcompat("Level"),
$bsqlch->strdbcompat("StartTime"),
$bsqlch->strdbcompat("StartTime"),
$bsqlch->strdbcompat("EndTime"),
$bsqlch->strdbcompat("JobBytes"),
$bsqlch->strdbcompat("JobStatus"),
$bsqlch->strdbcompat("JobStatus"),
$bsqlch->strdbcompat("ClientId"),
'duration' => $duration,
)
);
$select->join(
$bsqlch->strdbcompat("Client"),
$bsqlch->strdbcompat("Job.ClientId = Client.ClientId"),
$bsqlch->strdbcompat("Client"),
$bsqlch->strdbcompat("Job.ClientId = Client.ClientId"),
array($bsqlch->strdbcompat("ClientName") => $bsqlch->strdbcompat("Name"))
);

$select->where(
"(" .
"(" .
$bsqlch->strdbcompat("JobStatus") . " = 'T' OR " .
$bsqlch->strdbcompat("JobStatus") . " = 'W' ) AND (" .
$bsqlch->strdbcompat("StartTime") . " >= " . $interval . " OR " .
$bsqlch->strdbcompat("EndTime") . " >= " . $interval . ")"
);

if($order_by != null && $order != null) {
if($order_by != null && $order != null) {
$select->order($bsqlch->strdbcompat($order_by) . " " . $order);
}
else {
Expand All @@ -280,13 +306,13 @@ public function getLast24HoursSuccessfulJobs($paginated=false, $order_by=null, $
);
$paginator = new Paginator($paginatorAdapter);
return $paginator;
}
}
else {
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
}

public function getLast24HoursUnsuccessfulJobs($paginated=false, $order_by=null, $order=null)
{
if($this->getDbDriverConfig() == "Pdo_Mysql" || $this->getDbDriverConfig() == "Mysqli") {
Expand All @@ -309,23 +335,24 @@ public function getLast24HoursUnsuccessfulJobs($paginated=false, $order_by=null,
$bsqlch->strdbcompat("StartTime"),
$bsqlch->strdbcompat("EndTime"),
$bsqlch->strdbcompat("JobStatus"),
$bsqlch->strdbcompat("ClientId"),
'duration' => $duration,
)
);
$select->join(
$bsqlch->strdbcompat("Client"),
$bsqlch->strdbcompat("Job.ClientId = Client.ClientId"),
$bsqlch->strdbcompat("Client"),
$bsqlch->strdbcompat("Job.ClientId = Client.ClientId"),
array($bsqlch->strdbcompat("ClientName") => $bsqlch->strdbcompat("Name"))
);
$select->where(
"(" .
"(" .
$bsqlch->strdbcompat("JobStatus") . " = 'A' OR " .
$bsqlch->strdbcompat("JobStatus") . " = 'E' OR " .
$bsqlch->strdbcompat("JobStatus") . " = 'e' OR " .
$bsqlch->strdbcompat("JobStatus") . " = 'f' ) AND (" .
$bsqlch->strdbcompat("StartTime") . " >= " . $interval . " OR " .
$bsqlch->strdbcompat("EndTime") . " >= " . $interval . ")"
);
);

if($order_by != null && $order != null) {
$select->order($bsqlch->strdbcompat($order_by) . " " . $order);
Expand All @@ -346,20 +373,20 @@ public function getLast24HoursUnsuccessfulJobs($paginated=false, $order_by=null,
return $paginator;
}
else {
$resultSet = $this->tableGateway->selectWith($select);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
}
public function getJobCountLast24HoursByStatus($status)

public function getJobCountLast24HoursByStatus($status)
{
$current_time = date("Y-m-d H:i:s",time());
$back24h_time = date("Y-m-d H:i:s",time() - (60*60*23));

$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
$select = new Select();
$select->from($bsqlch->strdbcompat("Job"));

if($status == "C")
{
$select->where(
Expand Down Expand Up @@ -527,19 +554,19 @@ public function getJobCountLast24HoursByStatus($status)
$bsqlch->strdbcompat("EndTime") . " >= '" . $back24h_time . "'"
);
}

$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Job());
$rowset = new DbSelect(
$select,
$this->tableGateway->getAdapter(),
$resultSetPrototype
);
$num = $rowset->count();
$num = $rowset->count();

return $num;
}

public function getJobNum()
{
$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
Expand All @@ -552,46 +579,46 @@ public function getJobNum()
$this->tableGateway->getAdapter(),
$resultSetPrototype
);
$num = $rowset->count();
$num = $rowset->count();
return $num;
}
public function getLastSuccessfulClientJob($id)

public function getLastSuccessfulClientJob($id)
{
$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
$select = new Select();
$select->from($bsqlch->strdbcompat("Job"));
$select->where(
$select->where(
$bsqlch->strdbcompat("ClientId") . " = " . $id . " AND (" .
$bsqlch->strdbcompat("JobStatus") . " = 'T' OR " .
$bsqlch->strdbcompat("JobStatus") . " = 'W')"
);
$select->order($bsqlch->strdbcompat("JobId") . " DESC");
$select->limit(1);

$rowset = $this->tableGateway->selectWith($select);
$row = $rowset->current();

if(!$row) {
// Note: If there is no record, a job for this client was never executed.
// Exception: throw new \Exception("Could not find row $jobid");
$row = null;
}

return $row;
}

public function getStoredBytes7Days()
public function getStoredBytes7Days()
{
$end = date("Y-m-d H:i:s",time());
$start = date("Y-m-d H:i:s",time() - (60*60*23*7));

$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
$select = new Select();
$select->from($bsqlch->strdbcompat("Job"));
$select->columns(array(
$bsqlch->strdbcompat("EndTime"),
$bsqlch->strdbcompat("JobBytes"),
$bsqlch->strdbcompat("JobBytes"),
true
)
);
Expand All @@ -600,19 +627,19 @@ public function getStoredBytes7Days()
$bsqlch->strdbcomapt("EndTime") . " <= '" . $end . "'"
);
$select->order($bsqlch->strdbcompat("EndTime" . " ASC"));

$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
public function getStoredBytes14Days()

public function getStoredBytes14Days()
{
$bsqlch = new BareosSqlCompatHelper($this->getDbDriverConfig());
$select = new Select();
$select->from($bsqlch->strdbcompat("Job"));

$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}

}

0 comments on commit 83f1077

Please sign in to comment.