BUGFIX: timestamps of failed runs were wrong

This commit is contained in:
Jeroen De Meerleer 2022-05-20 11:06:22 +02:00
parent d0974325f5
commit 3352fc52f6
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 13 additions and 1 deletions

View File

@ -185,4 +185,16 @@ class Run
return $this;
}
public function toArray(): array
{
return [
'id' => $this->getId(),
'exitcode' => $this->getExitcode(),
'output' => $this->getOutput(),
'runtime' => $this->getRuntime(),
'timestamp' => $this->getTimestamp(),
'flags' => $this->getFlags(),
'job' => $this->getJob()->getId(),
];
}
}

View File

@ -91,7 +91,7 @@ class JobRepository extends EntityRepository
$failedruns = $runRepo->getRunsForJob($job, true, $jobData['fail-days']);
$failed = count($failedruns);
$all = count($runRepo->getRunsForJob($job, false, $jobData['fail-days']));
$job->setData('lastfail', $failedruns[0] ?? NULL);
$job->setData('lastfail', isset($failedruns[0]) ? $failedruns[0]->toArray() : NULL);
$job->setData('needschecking', $all > 0 && (($failed / $all) * 100) > $jobData['fail-pct']);
if(!empty($jobData['containertype']) && $jobData['containertype'] != 'none') {
$job->setData('host-displayname', $jobData['service'] . ' on ' . $jobData['host']);