fix: type errors

This commit is contained in:
karishmas6
2024-10-26 01:01:13 +05:30
parent 9c071a1d9b
commit 7f4b6231ec

View File

@@ -2,7 +2,7 @@ import { Queue, Worker } from 'bullmq';
import IORedis from 'ioredis'; import IORedis from 'ioredis';
import logger from './logger'; import logger from './logger';
import { handleRunRecording } from "./workflow-management/scheduler"; import { handleRunRecording } from "./workflow-management/scheduler";
import Robot from './models/robot'; import Robot from './models/Robot';
import { computeNextRun } from './utils/schedule'; import { computeNextRun } from './utils/schedule';
const connection = new IORedis({ const connection = new IORedis({
@@ -40,15 +40,18 @@ worker.on('completed', async (job: any) => {
const lastRunAt = new Date(); const lastRunAt = new Date();
// Compute the next run date // Compute the next run date
const nextRunAt = computeNextRun(robot.schedule.cronExpression, robot.schedule.timezone); if (robot.schedule && robot.schedule.cronExpression && robot.schedule.timezone) {
const nextRunAt = computeNextRun(robot.schedule.cronExpression, robot.schedule.timezone) || undefined;
await robot.update({ await robot.update({
schedule: { schedule: {
...robot.schedule, ...robot.schedule,
lastRunAt, lastRunAt,
nextRunAt, nextRunAt,
}, },
}); });
} else {
logger.error('Robot schedule, cronExpression, or timezone is missing.');
}
} }
}); });