Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

enh(resources): in detail, fetch downtime only if needed #12032

Open
wants to merge 1 commit into
base: dev-21.10.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions src/Centreon/Domain/Monitoring/ResourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ public function findResources(ResourceFilter $filter): array
*/
public function enrichHostWithDetails(ResourceEntity $resource): void
{
$downtimes = $this->monitoringRepository->findDowntimes(
$resource->getId(),
0
);
$resource->setDowntimes($downtimes);
if ($resource->getInDowntime() === true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need to rename later getInDowtime by isInDowntime

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did not take the time to do it as multiple impacts which are not that mandatory as 21.10 will reach EOL soon

$downtimes = $this->monitoringRepository->findDowntimes(
$resource->getId(),
0
);
$resource->setDowntimes($downtimes);
}

if ($resource->getAcknowledged()) {
$acknowledgements = $this->monitoringRepository->findAcknowledgements(
Expand Down Expand Up @@ -196,11 +198,13 @@ public function enrichServiceWithDetails(ResourceEntity $resource): void
throw new ResourceException(_('Parent of resource type service cannot be null'));
}

$downtimes = $this->monitoringRepository->findDowntimes(
$resource->getParent()->getId(),
$resource->getId()
);
$resource->setDowntimes($downtimes);
if ($resource->getInDowntime() === true) {
$downtimes = $this->monitoringRepository->findDowntimes(
$resource->getParent()->getId(),
$resource->getId()
);
$resource->setDowntimes($downtimes);
}

if ($resource->getAcknowledged()) {
$acknowledgements = $this->monitoringRepository->findAcknowledgements(
Expand Down Expand Up @@ -236,11 +240,13 @@ public function enrichServiceWithDetails(ResourceEntity $resource): void
*/
public function enrichMetaServiceWithDetails(ResourceEntity $resource): void
{
$downtimes = $this->monitoringRepository->findDowntimes(
$resource->getHostId(),
$resource->getServiceId()
);
$resource->setDowntimes($downtimes);
if ($resource->getInDowntime() === true) {
$downtimes = $this->monitoringRepository->findDowntimes(
$resource->getHostId(),
$resource->getServiceId()
);
$resource->setDowntimes($downtimes);
}

if ($resource->getAcknowledged()) {
$acknowledgements = $this->monitoringRepository->findAcknowledgements(
Expand Down