From 4987f818c5f4f53911a9730e29f689c11837c597 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Fri, 28 May 2021 15:00:24 +0200 Subject: [PATCH] NEW FEATURE: multiple wrong exit statuses --- src/Controller/JobController.php | 2 +- src/Repository/Job.php | 4 ++-- src/Repository/Run.php | 7 ++++--- templates/job/edit.html.twig | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Controller/JobController.php b/src/Controller/JobController.php index 2178bd8..b98210d 100644 --- a/src/Controller/JobController.php +++ b/src/Controller/JobController.php @@ -32,7 +32,7 @@ class JobController extends Controller if($this->getRequest()->getMethod() == 'GET') { $job = $jobRepo->getJob($id); - $runs = $runRepo->getRunsForJob($id, $all != 'all' ? [$job['data']['response']] : []); + $runs = $runRepo->getRunsForJob($id, $all != 'all' ? array_merge($job['data']['response'] ?? [], $job['data']['http-status'] ?? []) : []); return $this->render('job/view.html.twig', ['job' => $job, 'runs' => $runs, 'allruns' => $all == 'all']); } elseif($this->getRequest()->getMethod() == 'DELETE') { $success = $jobRepo->deleteJob($id); diff --git a/src/Repository/Job.php b/src/Repository/Job.php index 1b37861..b12f009 100644 --- a/src/Repository/Job.php +++ b/src/Repository/Job.php @@ -266,7 +266,7 @@ class Job extends Repository { case 'command': $values['data']['command'] = $values['command']; - $values['data']['response'] = $values['response']; + $values['data']['response'] = explode(',', $values['response']); break; case 'reboot': $values['data']['reboot-command'] = $values['reboot-command']; @@ -287,7 +287,7 @@ class Job extends Repository case 'http': $parsedUrl = parse_url($values['url']); $values['data']['url'] = $values['url']; - $values['data']['response'] = $values['response']; + $values['data']['http-status'] = explode(',', $values['http-status']); $values['data']['basicauth-username'] = $values['basicauth-username']; if(empty($parsedUrl['host'])) { throw new \InvalidArgumentException('Some data was invalid'); diff --git a/src/Repository/Run.php b/src/Repository/Run.php index 8dd3199..cb2689e 100644 --- a/src/Repository/Run.php +++ b/src/Repository/Run.php @@ -13,12 +13,13 @@ class Run extends Repository $runsSql = "SELECT * FROM run WHERE job_id = :job"; $params = [':job' => $id]; if (!empty($excludedexitcodes)) { - $runsSql .= ' AND exitcode NOT in ('; + $runsSql .= ' AND exitcode NOT in '; + $exitcodes = []; foreach($excludedexitcodes as $key => $exitcode) { - $runsSql .= ':code' . $key; + $exitcodes[] = ':code' . $key; $params[':code' . $key] = $exitcode; } - $runsSql .= ')'; + $runsSql .= '(' . implode(',', $exitcodes) . ')'; } if ($ordered) $runsSql .= ' ORDER by timestamp DESC'; $runsStmt = $this->dbcon->prepare($runsSql); diff --git a/templates/job/edit.html.twig b/templates/job/edit.html.twig index 1023863..412c635 100644 --- a/templates/job/edit.html.twig +++ b/templates/job/edit.html.twig @@ -152,8 +152,8 @@
- - + +