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 22, 2023
1 parent 8eb2165 commit 807965e
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,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 @@ -126,6 +126,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 807965e

Please sign in to comment.