mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
ServicetemplateController: helper method
Helps to shorten lines for now
This commit is contained in:
parent
aa3a8987ba
commit
0bfd245cb2
@ -59,10 +59,10 @@ class ServicetemplateController extends SimpleController
|
|||||||
$query = $db->select()->from(
|
$query = $db->select()->from(
|
||||||
['s' => 'icinga_service'],
|
['s' => 'icinga_service'],
|
||||||
[
|
[
|
||||||
'cnt_templates' => "COALESCE(SUM(CASE WHEN s.object_type = 'template' THEN 1 ELSE 0 END), 0)",
|
'cnt_templates' => $this->getSummaryLine('template'),
|
||||||
'cnt_objects' => "COALESCE(SUM(CASE WHEN s.object_type = 'object' THEN 1 ELSE 0 END), 0)",
|
'cnt_objects' => $this->getSummaryLine('object'),
|
||||||
'cnt_apply_rules' => "COALESCE(SUM(CASE WHEN s.object_type = 'apply' AND s.service_set_id IS NULL THEN 1 ELSE 0 END), 0)",
|
'cnt_apply_rules' => $this->getSummaryLine('apply', 's.service_set_id IS NULL'),
|
||||||
'cnt_set_members' => "COALESCE(SUM(CASE WHEN s.object_type = 'apply' AND s.service_set_id IS NOT NULL THEN 1 ELSE 0 END), 0)",
|
'cnt_set_members' => $this->getSummaryLine('apply', 's.service_set_id IS NOT NULL'),
|
||||||
]
|
]
|
||||||
)->joinLeft(
|
)->joinLeft(
|
||||||
['ps' => 'icinga_service_inheritance'],
|
['ps' => 'icinga_service_inheritance'],
|
||||||
@ -73,6 +73,14 @@ class ServicetemplateController extends SimpleController
|
|||||||
return $db->fetchRow($query);
|
return $db->fetchRow($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getSummaryLine($type, $extra = null)
|
||||||
|
{
|
||||||
|
if ($extra !== null) {
|
||||||
|
$extra = " AND $extra";
|
||||||
|
}
|
||||||
|
return "COALESCE(SUM(CASE WHEN s.object_type = '${type}'${extra} THEN 1 ELSE 0 END), 0)";
|
||||||
|
}
|
||||||
|
|
||||||
protected function requireTemplate()
|
protected function requireTemplate()
|
||||||
{
|
{
|
||||||
return IcingaService::load([
|
return IcingaService::load([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user