From 17072dee45ef65bdcd61644b6d325c5d28c386ac Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 31 Aug 2018 11:06:57 +0200 Subject: [PATCH 1/4] Saving all runs in database --- runnow.php | 2 +- webcron.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runnow.php b/runnow.php index 82fdc00..0559098 100644 --- a/runnow.php +++ b/runnow.php @@ -69,7 +69,7 @@ if (filter_var($jobnameResult[0]["url"], FILTER_VALIDATE_URL)) { } } } -if($nosave !== true && $statuscode != $jobnameResult[0]["expected"]) { +if($nosave !== true) { $stmt = $db->prepare("INSERT INTO runs(job, statuscode, result, timestamp) VALUES(?, ?, ?, ?)"); $stmt->execute(array($jobID, $statuscode, $body, $timestamp)); } diff --git a/webcron.php b/webcron.php index 5b59874..fe368db 100644 --- a/webcron.php +++ b/webcron.php @@ -92,7 +92,7 @@ foreach ($results as $result) { } } - if($nosave !== true && $statuscode != $result["expected"]) { + if($nosave !== true) { $stmt = $db->prepare("INSERT INTO runs(job, statuscode, result, timestamp) VALUES(?, ?, ?, ?)"); $stmt->execute(array($result['jobID'], $statuscode, $body, time())); } From 890c392bcf29a6dc6b61b11a5630f656e7677130 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 31 Aug 2018 11:16:14 +0200 Subject: [PATCH 2/4] Fetching all runs only if neccesary --- runs.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runs.php b/runs.php index edd1353..e06ee90 100644 --- a/runs.php +++ b/runs.php @@ -35,7 +35,11 @@ if ($jobnameResult[0]["user"] != $_SESSION["userID"]) { } $jobName = $jobnameResult[0]['name']; -$runsForJob = $db->prepare("SELECT runs.*, jobs.name FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?"); +$runsForJobQry = "SELECT runs.*, jobs.name FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?"; +if(!isset($_GET['allruns']) || $_GET['allruns'] == 1) { + $runsForJobQry .= " AND runs.statuscode = jobs.expected"; +} +$runsForJob = $db->prepare($runsForJobQry); $runsForJob->execute(array($_GET['jobID'])); $runsForJobResult = $runsForJob->fetchAll(PDO::FETCH_ASSOC); From 2dbbb2b0cba13b118c922abed99a65583e2c8513 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 31 Aug 2018 11:42:52 +0200 Subject: [PATCH 3/4] Updated template --- runs.php | 4 +++- templates/runs.html.twig | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/runs.php b/runs.php index e06ee90..d73da89 100644 --- a/runs.php +++ b/runs.php @@ -36,8 +36,10 @@ if ($jobnameResult[0]["user"] != $_SESSION["userID"]) { $jobName = $jobnameResult[0]['name']; $runsForJobQry = "SELECT runs.*, jobs.name FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?"; +$allruns = true; if(!isset($_GET['allruns']) || $_GET['allruns'] == 1) { $runsForJobQry .= " AND runs.statuscode = jobs.expected"; + $allruns = false; } $runsForJob = $db->prepare($runsForJobQry); $runsForJob->execute(array($_GET['jobID'])); @@ -59,7 +61,7 @@ foreach($runsForJobResult as $key=>$value) { $count++; } -$twig_vars = array('runs' => $runsForJobRendered, "title" => $jobName); +$twig_vars = array('jobID' => $_GET['jobID'], 'runs' => $runsForJobRendered, 'allruns' => $allruns, "title" => $jobName); //echo $twig->render('overview.html.twig', array('the' => 'variables', 'go' => 'here')); echo $twig->render('runs.html.twig', $twig_vars); diff --git a/templates/runs.html.twig b/templates/runs.html.twig index 445e434..47b85a1 100644 --- a/templates/runs.html.twig +++ b/templates/runs.html.twig @@ -2,6 +2,11 @@ {% block title %}Overview of run for {{ title }}{% endblock %} {% block content %}

Overview of runs for {{ title }}

+{% if allruns %} +

Only show failed runs

+{% elseif not allruns %} +

Only all failed runs

+{% endif %}
{% for run in runs %}
From 896b839c27bef8a40b429382dd28bd710446acd5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 31 Aug 2018 12:02:38 +0200 Subject: [PATCH 4/4] Bugfixes --- runs.php | 4 ++-- templates/runs.html.twig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runs.php b/runs.php index d73da89..7885a89 100644 --- a/runs.php +++ b/runs.php @@ -37,8 +37,8 @@ $jobName = $jobnameResult[0]['name']; $runsForJobQry = "SELECT runs.*, jobs.name FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?"; $allruns = true; -if(!isset($_GET['allruns']) || $_GET['allruns'] == 1) { - $runsForJobQry .= " AND runs.statuscode = jobs.expected"; +if(!(isset($_GET['allruns']) && $_GET['allruns'] == 1)) { + $runsForJobQry .= " AND runs.statuscode <> jobs.expected"; $allruns = false; } $runsForJob = $db->prepare($runsForJobQry); diff --git a/templates/runs.html.twig b/templates/runs.html.twig index 47b85a1..aa5ff70 100644 --- a/templates/runs.html.twig +++ b/templates/runs.html.twig @@ -5,7 +5,7 @@ {% if allruns %}

Only show failed runs

{% elseif not allruns %} -

Only all failed runs

+

Show all runs

{% endif %}
{% for run in runs %}