feat: update last run and next run values
This commit is contained in:
@@ -32,6 +32,23 @@ const worker = new Worker('workflow', async job => {
|
|||||||
|
|
||||||
worker.on('completed', async (job: any) => {
|
worker.on('completed', async (job: any) => {
|
||||||
logger.log(`info`, `Job ${job.id} completed for ${job.data.runId}`);
|
logger.log(`info`, `Job ${job.id} completed for ${job.data.runId}`);
|
||||||
|
const robot = await Robot.findOne({ where: { 'recording_meta.id': job.data.id } });
|
||||||
|
if (robot) {
|
||||||
|
// Update `lastRunAt` to the current time
|
||||||
|
const lastRunAt = new Date();
|
||||||
|
|
||||||
|
// Compute the next run date
|
||||||
|
const nextRunAt = computeNextRun(robot.schedule.cronExpression, robot.schedule.timezone);
|
||||||
|
|
||||||
|
await robot.update({
|
||||||
|
schedule: {
|
||||||
|
...robot.schedule,
|
||||||
|
lastRunAt,
|
||||||
|
nextRunAt,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', async (job: any, err) => {
|
worker.on('failed', async (job: any, err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user