record last cron expression (and stub owner_uid) used by scheduled task

This commit is contained in:
Andrew Dolgov 2025-05-04 18:06:43 +03:00
parent fc059fc0fc
commit 5263a07f61
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
5 changed files with 15 additions and 2 deletions

View File

@ -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:
*

View File

@ -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>

View File

@ -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();

View File

@ -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;

View File

@ -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;