This commit is contained in:
Arunavo Ray
2025-08-28 15:46:05 +05:30
parent d9bfc59a2d
commit be5f2e6c3d

View File

@@ -204,18 +204,20 @@ export function mapDbScheduleToUi(dbSchedule: DbScheduleConfig): any {
let intervalSeconds = 86400; // Default to daily (24 hours) let intervalSeconds = 86400; // Default to daily (24 hours)
if (dbSchedule.interval) { if (dbSchedule.interval) {
// Check if it's already a number (seconds), use it directly
if (typeof dbSchedule.interval === 'number') {
intervalSeconds = dbSchedule.interval;
} else if (typeof dbSchedule.interval === 'string') {
// Check if it's a cron expression // Check if it's a cron expression
const cronMatch = dbSchedule.interval.match(/0 \*\/(\d+) \* \* \*/); const cronMatch = dbSchedule.interval.match(/0 \*\/(\d+) \* \* \*/);
if (cronMatch) { if (cronMatch) {
intervalSeconds = parseInt(cronMatch[1]) * 3600; intervalSeconds = parseInt(cronMatch[1]) * 3600;
} else if (typeof dbSchedule.interval === 'number') {
// If it's already a number (seconds), use it directly
intervalSeconds = dbSchedule.interval;
} else if (dbSchedule.interval === "0 2 * * *") { } else if (dbSchedule.interval === "0 2 * * *") {
// Daily at 2 AM // Daily at 2 AM
intervalSeconds = 86400; intervalSeconds = 86400;
} }
} }
}
return { return {
enabled: dbSchedule.enabled || false, enabled: dbSchedule.enabled || false,