summaryrefslogtreecommitdiff
diff options
authorAndrew Dolgov <[email protected]>2025-05-04 18:06:43 +0300
committerAndrew Dolgov <[email protected]>2025-05-04 18:06:43 +0300
commit5263a07f61698eb26e0482129d66c5ab4be1c9c5 (patch)
tree2b8b58cc141325a5bff5ebcefedafac52a626fbb
parentfc059fc0fc85d0bfbc74f6984fc10e857d21df6c (diff)
record last cron expression (and stub owner_uid) used by scheduled taskplugin-cringe
-rw-r--r--classes/Config.php2
-rw-r--r--classes/Pref_System.php3
-rw-r--r--classes/Scheduler.php2
-rw-r--r--sql/pgsql/migrations/151.sql6
-rw-r--r--sql/pgsql/schema.sql4
5 files changed, 15 insertions, 2 deletions
diff --git a/classes/Config.php b/classes/Config.php
index c413317be..a4d2eb6b3 100644
--- a/classes/Config.php
+++ b/classes/Config.php
@@ -6,7 +6,7 @@ class Config {
const T_STRING = 2;
const T_INT = 3;
- const SCHEMA_VERSION = 150;
+ const SCHEMA_VERSION = 151;
/** override default values, defined below in _DEFAULTS[], prefixing with _ENVVAR_PREFIX:
*
diff --git a/classes/Pref_System.php b/classes/Pref_System.php
index c5d7ab606..7946dc293 100644
--- a/classes/Pref_System.php
+++ b/classes/Pref_System.php
@@ -33,6 +33,7 @@ class Pref_System extends Handler_Administrative {
<table width='100%' class='event-log'>
<tr>
<th><?= __("Task name") ?></th>
+ <th><?= __("Schedule") ?></th>
<th><?= __("Last executed") ?></th>
<th><?= __("Duration (seconds)") ?></th>
<th><?= __("Return code") ?></th>
@@ -40,6 +41,7 @@ class Pref_System extends Handler_Administrative {
<?php
$task_records = ORM::for_table('ttrss_scheduled_tasks')
+ ->order_by_asc(['last_cron_expression', 'task_name'])
->find_many();
foreach ($task_records as $task) {
@@ -48,6 +50,7 @@ class Pref_System extends Handler_Administrative {
?>
<tr>
<td class="<?= $row_style ?>"><?= $task->task_name ?></td>
+ <td><?= $task->last_cron_expression ?></td>
<td><?= TimeHelper::make_local_datetime($task->last_run) ?></td>
<td><?= $task->last_duration ?></td>
<td><?= $task->last_rc ?></td>
diff --git a/classes/Scheduler.php b/classes/Scheduler.php
index ce6a2f67d..77e858b56 100644
--- a/classes/Scheduler.php
+++ b/classes/Scheduler.php
@@ -117,6 +117,7 @@ class Scheduler {
$task_record->last_run = Db::NOW();
$task_record->last_duration = $task_duration;
$task_record->last_rc = $rc;
+ $task_record->last_cron_expression = $task['cron']->getExpression();
$task_record->save();
} else {
@@ -127,6 +128,7 @@ class Scheduler {
'last_duration' => $task_duration,
'last_rc' => $rc,
'last_run' => Db::NOW(),
+ 'last_cron_expression' => $task['cron']->getExpression()
]);
$task_record->save();
diff --git a/sql/pgsql/migrations/151.sql b/sql/pgsql/migrations/151.sql
new file mode 100644
index 000000000..c3d9c159b
--- /dev/null
+++ b/sql/pgsql/migrations/151.sql
@@ -0,0 +1,6 @@
+alter table ttrss_scheduled_tasks add column owner_uid integer default null references ttrss_users(id) ON DELETE CASCADE;
+alter table ttrss_scheduled_tasks add column last_cron_expression varchar(250);
+
+update ttrss_scheduled_tasks set last_cron_expression = '';
+
+alter table ttrss_scheduled_tasks alter column last_cron_expression set not null;
diff --git a/sql/pgsql/schema.sql b/sql/pgsql/schema.sql
index 3145629fc..21e3fd83a 100644
--- a/sql/pgsql/schema.sql
+++ b/sql/pgsql/schema.sql
@@ -400,6 +400,8 @@ create table ttrss_scheduled_tasks(
task_name varchar(250) unique not null,
last_duration integer not null,
last_rc integer not null,
- last_run timestamp not null default NOW());
+ last_run timestamp not null default NOW(),
+ last_cron_expression varchar(250) not null,
+ owner_uid integer default null references ttrss_users(id) ON DELETE CASCADE);
commit;