UnreachableParent: Eliminate duplicate nodes

Nodes might be referenced by multiple independent paths, which
might lead to the same root problem multiple times.
This commit is contained in:
Johannes Meyer 2025-01-15 10:34:13 +01:00
parent 02ff5d8ea8
commit e5b499bbdb
3 changed files with 26 additions and 1 deletions

View file

@ -5,6 +5,7 @@
namespace Icinga\Module\Icingadb\Model;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use Icinga\Module\Icingadb\Model\UnreachableParent\ResultSet;
use InvalidArgumentException;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behaviors;
@ -112,6 +113,8 @@ class UnreachableParent extends DependencyNode
)
));
$query->setResultSetClass(ResultSet::class);
return $query;
}

View file

@ -0,0 +1,23 @@
<?php
namespace Icinga\Module\Icingadb\Model\UnreachableParent;
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Traversable;
class ResultSet extends VolatileStateResults
{
protected function yieldTraversable(Traversable $traversable)
{
$knownIds = [];
foreach ($traversable as $value) {
if (isset($knownIds[$value->id])) {
continue;
}
$knownIds[$value->id] = true;
yield $value;
}
}
}

View file

@ -655,7 +655,6 @@ class ObjectDetail extends BaseHtmlElement
'service.host',
'service.host.state'
])
->setResultSetClass(VolatileStateResults::class)
->orderBy([
'host.state.severity',
'host.state.last_state_change',