diff --git a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte index 8b934ab967..259c34ec5b 100644 --- a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte +++ b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte @@ -8,23 +8,23 @@ const CRON_EXPRESSIONS = [ { label: "Every Minute", - value: "* * * * *" + value: "* * * * *", }, { label: "Every Hour", - value: "0 * * * *" + value: "0 * * * *", }, { label: "Every Morning at 8AM", - value: "0 8 * * *" + value: "0 8 * * *", }, { label: "Every Night at Midnight", - value: "0 0 * * *" + value: "0 0 * * *", }, { label: "Every Budibase Reboot", - value: "@reboot" + value: "@reboot", }, ] @@ -33,18 +33,26 @@
- + {#if presets} - {/if}
diff --git a/packages/server/src/api/controllers/automation.js b/packages/server/src/api/controllers/automation.js index 8e9e23be40..20e54fe238 100644 --- a/packages/server/src/api/controllers/automation.js +++ b/packages/server/src/api/controllers/automation.js @@ -39,8 +39,6 @@ function cleanAutomationInputs(automation) { * @param {string} appId The ID of the app in which we are checking for webhooks * @param {object|undefined} oldAuto The old automation object if updating/deleting * @param {object|undefined} newAuto The new automation object if creating/updating - * @returns {Promise} After this is complete the new automation object may have been updated and should be - * written to DB (this does not write to DB as it would be wasteful to repeat). */ async function checkForCronTriggers({ appId, oldAuto, newAuto }) { const oldTrigger = oldAuto ? oldAuto.definition.trigger : null @@ -53,11 +51,13 @@ async function checkForCronTriggers({ appId, oldAuto, newAuto }) { ) } + const isLive = auto => auto && auto.live + const cronTriggerRemoved = isCronTrigger(oldAuto) && !isCronTrigger(newAuto) && oldTrigger.cronJobId - const cronTriggerDeactivated = !newAuto.live && oldAuto.live + const cronTriggerDeactivated = !isLive(newAuto) && isLive(oldAuto) - const cronTriggerActivated = newAuto.live && !oldAuto.live + const cronTriggerActivated = isLive(newAuto) && !isLive(oldAuto) if (cronTriggerRemoved || cronTriggerDeactivated) { await triggers.automationQueue.removeRepeatableByKey(oldTrigger.cronJobId)