From a0fd4aea60933e74a5ab9e236a099af921551c7d Mon Sep 17 00:00:00 2001 From: axeloz <1597611+axeloz@users.noreply.github.com> Date: Fri, 17 Dec 2021 20:11:39 +0100 Subject: [PATCH] Update DB.php --- web/DB.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/web/DB.php b/web/DB.php index 18c75d9..137d69f 100644 --- a/web/DB.php +++ b/web/DB.php @@ -34,11 +34,22 @@ class DB { } - public function get_all_tasks() { - $query = ' - SELECT id, host, type, params, creation_date, frequency, last_execution, active - FROM tasks - '; + public function get_all_tasks($status = null) { + if (is_null($status)) { + $query = ' + SELECT id, host, type, params, creation_date, frequency, last_execution, active + FROM tasks + '; + } + else { + $query = ' + SELECT DISTINCT t.id, t.host, t.type, t.params, t.creation_date, t.last_execution, t.active + FROM tasks as t + JOIN tasks_history as h ON (h.task_id = t.id) + WHERE h.status = '.intval($status).' AND h.datetime = t.last_execution + '; + } + return $this->query($query); }