Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/modules/workspace/services/testflow-schedular.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ export class TestflowSchedulerService {
runCycle: RunCycleConfig,
runApis: (schedularId: string) => Promise<void>,
afterJobCreate: (cronExpression: string) => void,
jobName: string,
cronExpression: string,
schedularId: string,
timezone: string = "UTC", // Always use UTC by default
): Promise<boolean> {
if (!cronExpression) {
console.error(`Invalid run cycle configuration for job ${jobName}`);
this.logger.log(`Invalid run cycle configuration for job ${jobName}`);
this.logger.log(`Invalid run cycle configuration for job ${schedularId}`);
return false;
}
try {
Expand Down Expand Up @@ -114,27 +112,27 @@ export class TestflowSchedulerService {
await runApis(schedularId);
} catch (error) {
this.logger.error(
`Error executing job ${jobName}: ${error.message}`,
`Error executing job ${schedularId}: ${error.message}`,
error.stack
);
}
}
// Handle one-time jobs
if (runCycle.type === RunCycleEnum.ONCE) {
job.stop();
this.schedulerRegistry.deleteCronJob(jobName);
this.schedulerRegistry.deleteCronJob(schedularId);
}
},
null, // onComplete callback
false, // start - we'll call start() manually
timezone, // Set timezone to UTC
);
this.schedulerRegistry.addCronJob(jobName, job);
this.schedulerRegistry.addCronJob(schedularId, job);
job.start();
return true;
} catch (error) {
this.logger.error(
`Failed to create scheduler job ${jobName}: ${error.message}`,
`Failed to create scheduler job ${schedularId}: ${error.message}`,
error.stack
);
return false;
Expand Down
4 changes: 1 addition & 3 deletions src/modules/workspace/services/testflow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export class TestflowService implements OnModuleInit {
cronExpression: _cronExpression,
});
},
schedule.schedularName,
cronExpression,
schedule.id,
"UTC",
Expand Down Expand Up @@ -282,9 +281,9 @@ export class TestflowService implements OnModuleInit {
cronExpression: _cronExpression,
});
},
schedular.schedularName,
cronExpression,
scheduleId,
"UTC",
);
}
}
Expand Down Expand Up @@ -640,7 +639,6 @@ export class TestflowService implements OnModuleInit {
cronExpression: _cronExpression,
});
},
jobName,
cronExpression,
schedulerId,
"UTC",
Expand Down
Loading