ActivityLogTable: filter by host if given

In future we'll have better filtering possibilities, for now this scans all
rows with a matching service name in the table

fixes #1613
This commit is contained in:
Thomas Gelf 2019-01-11 12:24:29 +01:00
parent 119635d290
commit 92c05f49a3
2 changed files with 19 additions and 3 deletions

View File

@ -224,10 +224,13 @@ abstract class ObjectController extends ActionController
$db = $this->db();
$type = $this->getType();
(new ActivityLogTable($db))
$table = (new ActivityLogTable($db))
->setLastDeployedId($db->getLastDeploymentActivityLogId())
->filterObject('icinga_' . $type, $name)
->renderTo($this);
->filterObject('icinga_' . $type, $name);
if ($host = $this->params->get('host')) {
$table->filterHost($host);
}
$table->renderTo($this);
}
/**

View File

@ -113,6 +113,19 @@ class ActivityLogTable extends ZfQueryBasedTable
return $this;
}
public function filterHost($name)
{
$db = $this->db();
$filter = '%"host":' . json_encode($name) . '%';
$this->filters[] = ['('
. $db->quoteInto('l.old_properties LIKE ?', $filter)
. ' OR '
. $db->quoteInto('l.new_properties LIKE ?', $filter)
. ')', null];
return $this;
}
public function getColumns()
{
return [