MonitoredObject: Only select history entries for the respective object

And fix that the default sort order is not applied.

fixes #9963
This commit is contained in:
Johannes Meyer 2015-08-19 11:53:00 +02:00
parent 7812f6ddcc
commit 65806fafbf
2 changed files with 21 additions and 12 deletions

View File

@ -496,7 +496,8 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
*/ */
public function peekAhead($state = true) public function peekAhead($state = true)
{ {
return $this->query->peekAhead($state); $this->query->peekAhead($state);
return $this;
} }
/** /**

View File

@ -450,21 +450,29 @@ abstract class MonitoredObject implements Filterable
*/ */
public function fetchEventhistory() public function fetchEventhistory()
{ {
$eventHistory = $this->backend->select()->from('eventhistory', array( $eventHistory = $this->backend
'object_type', ->select()
'host_name', ->from(
'host_display_name', 'eventhistory',
'service_description', array(
'service_display_name', 'object_type',
'timestamp', 'host_name',
'state', 'host_display_name',
'output', 'service_description',
'type' 'service_display_name',
)) 'timestamp',
'state',
'output',
'type'
)
)
->where('object_type', $this->type)
->where('host_name', $this->host_name); ->where('host_name', $this->host_name);
if ($this->type === self::TYPE_SERVICE) { if ($this->type === self::TYPE_SERVICE) {
$eventHistory->where('service_description', $this->service_description); $eventHistory->where('service_description', $this->service_description);
} }
$this->eventhistory = $eventHistory->applyFilter($this->getFilter()); $this->eventhistory = $eventHistory->applyFilter($this->getFilter());
return $this; return $this;
} }