Skip to content

Commit

Permalink
SlaTimeline: Fix division by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Feb 13, 2023
1 parent 72bfa88 commit 7950d89
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public function setInitialHardState(int $state): self
/**
* Get the calculated SLA result of this timeline
*
* @return float
* @return ?float
*/
public function getResult(): float
public function getResult(): ?float
{
$problemTime = 0;
$activeDowntimes = 0;
Expand Down Expand Up @@ -97,6 +97,10 @@ public function getResult(): float
$this->problemTime = $problemTime;
$this->totalTime = $totalTime;

if ($totalTime <= 0) {
return null;
}

return 100 * ($totalTime - $problemTime) / $totalTime;
}

Expand Down

0 comments on commit 7950d89

Please sign in to comment.