mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 08:44:11 +02:00
Db: improve readability, less duplication
This commit is contained in:
parent
8c3f38c11b
commit
0e99120c75
@ -444,14 +444,16 @@ class Db extends DbConnection
|
||||
|
||||
$queries = array();
|
||||
$db = $this->db();
|
||||
$cnt = "COALESCE(SUM(CASE WHEN o.object_type = '%s' THEN 1 ELSE 0 END), 0)";
|
||||
|
||||
foreach ($types as $type) {
|
||||
$queries[] = $db->select()->from(
|
||||
array('o' => 'icinga_' . $type),
|
||||
array(
|
||||
'icinga_type' => "('" . $type . "')",
|
||||
'cnt_object' => "COALESCE(SUM(CASE WHEN o.object_type = 'object' THEN 1 ELSE 0 END), 0)",
|
||||
'cnt_template' => "COALESCE(SUM(CASE WHEN o.object_type = 'template' THEN 1 ELSE 0 END), 0)",
|
||||
'cnt_external' => "COALESCE(SUM(CASE WHEN o.object_type = 'external_object' THEN 1 ELSE 0 END), 0)",
|
||||
'cnt_object' => sprintf($cnt, 'object'),
|
||||
'cnt_template' => sprintf($cnt, 'template'),
|
||||
'cnt_external' => sprintf($cnt, 'external_object'),
|
||||
'cnt_total' => 'COUNT(*)',
|
||||
)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user