Merge pull request #11159 from kuangp/fix/backend-tasks

fix(tasks): set next run time relative to now
This commit is contained in:
Fredrik Adelöw
2022-05-03 16:35:29 +02:00
committed by GitHub
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)