added some todo comments

This commit is contained in:
HB9HIL
2024-04-23 10:50:57 +02:00
parent d9777bb85e
commit a16b70900b

View File

@@ -2,6 +2,9 @@
require_once './src/Cron/vendor/autoload.php';
// TODO
// Add 'add' / 'edit' functions to be able to add/edit the crons in the cron manager view
class cron extends CI_Controller
{
function __construct() {
@@ -38,6 +41,8 @@ class cron extends CI_Controller
// This is the main function, which handles all crons, runs them if enabled and writes the 'next run' timestamp to the database
// TODO Add an API Key to the cronjob to improve security?
$this->load->model('cron_model');
$crons = $this->cron_model->get_crons();
@@ -52,7 +57,10 @@ class cron extends CI_Controller
$isdue = $cronjob->isDue();
if ($isdue == true) {
$isdue_result = 'true';
echo "CRON: ".$cron->id." -> is due: ".$isdue_result."\n";
// TODO Add log_message level debug here to have logging for the cron manager
echo "CRON: ".$cron->id." -> is due: ".$isdue_result."\n";
echo "CRON: ".$cron->id." -> RUNNING...\n";
$url = base_url().$cron->function;
@@ -67,29 +75,29 @@ class cron extends CI_Controller
if ($crun !== false) {
echo "CRON: ".$cron->id." -> CURL Result: ".$crun."\n";
// TODO Proper testing if '!== false' is enough for all functions.
// TODO Make Curl Result available in Cron Manager view?
} else {
echo "ERROR: Something went wrong with ".$cron->id."\n";
// TODO Add a flag or some kind of warning for the cron manager view?
}
} else {
$isdue_result = 'false';
echo "CRON: ".$cron->id." -> is due: ".$isdue_result."\n";
}
$next_run = $cronjob->getNextRunDate(date('Y-m-d H:i:s'))->format('Y-m-d H:i:s');
echo "CRON: ".$cron->id." -> Next Run: ".$next_run."\n";
$this->cron_model->set_next_run($cron->id,$next_run);
} else {
echo 'CRON: '.$cron->id." is disabled.\n";
// set the next_run timestamp to null to indicate that this cron is disabled
// Set the next_run timestamp to null to indicate in the view/database that this cron is disabled
$this->cron_model->set_next_run($cron->id,null);
}