fix(tasks): set next run time relative to now

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2022-04-28 13:46:42 -04:00
parent 894f4022b6
commit ebbec677e1
2 changed files with 12 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-tasks': patch
---
Correctly set next run time for tasks
@@ -283,8 +283,13 @@ export class TaskWorker {
})}`,
);
nextRun = this.knex.client.config.client.includes('sqlite3')
? this.knex.raw('datetime(next_run_start_at, ?)', [`+${dt} seconds`])
: this.knex.raw(`next_run_start_at + interval '${dt} seconds'`);
? this.knex.raw(
`max(datetime(next_run_start_at, ?), datetime('now'))`,
[`+${dt} seconds`],
)
: this.knex.raw(
`greatest(next_run_start_at + interval '${dt} seconds', now())`,
);
}
const rows = await this.knex<DbTasksRow>(DB_TASKS_TABLE)