Fetch the service problem summary of a host with less redundant code

refs #9864
This commit is contained in:
Johannes Meyer 2015-08-11 13:52:21 +02:00
parent 78fdf85c7e
commit 00d143cb14
2 changed files with 19 additions and 14 deletions

View File

@ -121,19 +121,8 @@ class Monitoring_ListController extends Controller
'host_last_check' => $this->translate('Last Check')
), $query);
$summary = $this->backend->select()->from('Hostservicestatussummary', array(
'host_name',
'unhandled_service_count'
));
$summary->addFilter($query->getFilter());
$this->setupSortControl(array(
'host_severity' => $this->translate('Severity'),
'host_state' => $this->translate('Current State'),
'host_display_name' => $this->translate('Hostname'),
'host_address' => $this->translate('Address'),
'host_last_check' => $this->translate('Last Check')
), $summary);
$summary->limit($query->getLimit(), $query->getOffset());
$summary = $query->getQuery()->queryServiceProblemSummary();
$this->applyRestriction('monitoring/filter/objects', $summary);
$this->view->summary = $summary->fetchPairs();
}

View File

@ -449,4 +449,20 @@ SQL;
return $group;
}
}
/**
* Query the service problem summary for all hosts of this query's result set
*
* @return HostserviceproblemsummaryQuery
*/
public function queryServiceProblemSummary()
{
return $this->createSubQuery('Hostserviceproblemsummary')
->setHostStatusQuery($this)
->columns(array(
'host_name',
'unhandled_service_count'
)
);
}
}