TemplateUsageTable: Fix indrect object count

fixes #2806
This commit is contained in:
raviks789 2023-09-22 13:16:33 +02:00
parent 7c2a3f254b
commit ca855c6ee7

View File

@ -6,6 +6,7 @@ use Icinga\Authentication\Auth;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Module\Director\Db; use Icinga\Module\Director\Db;
use Icinga\Module\Director\Db\Branch\Branch; use Icinga\Module\Director\Db\Branch\Branch;
use Icinga\Module\Director\Db\IcingaObjectFilterHelper;
use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Objects\IcingaObject;
use gipfl\IcingaWeb2\Link; use gipfl\IcingaWeb2\Link;
use ipl\Html\Table; use ipl\Html\Table;
@ -119,12 +120,19 @@ class TemplateUsageTable extends Table
$templateType = $template->getShortTableName(); $templateType = $template->getShortTableName();
foreach ($this->getSummaryTables($templateType, $connection) as $type => $summaryTable) { foreach ($this->getSummaryTables($templateType, $connection) as $type => $summaryTable) {
$direct[$type] = $db $directTable = clone $summaryTable;
->query($summaryTable->filterTemplate($template, 'direct')->getQuery()) $inDirectTable = clone $summaryTable;
->rowCount();
$indirect[$type] = $db $direct[$type] = $db->query(
->query($summaryTable->filterTemplate($template, 'indirect')->getQuery()) $directTable
->rowCount(); ->filterTemplate($template, IcingaObjectFilterHelper::INHERIT_DIRECT)
->getQuery()
)->rowCount();
$indirect[$type] = $db->query(
$inDirectTable
->filterTemplate($template, IcingaObjectFilterHelper::INHERIT_INDIRECT)
->getQuery()
)->rowCount();
} }
$total = []; $total = [];