diff --git a/src/Entity/Run.php b/src/Entity/Run.php index f3623a5..49dc934 100644 --- a/src/Entity/Run.php +++ b/src/Entity/Run.php @@ -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(), + ]; + } } \ No newline at end of file diff --git a/src/Repository/JobRepository.php b/src/Repository/JobRepository.php index 975d675..76499c3 100644 --- a/src/Repository/JobRepository.php +++ b/src/Repository/JobRepository.php @@ -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']);