chore: add comments in update flow status

This commit is contained in:
Ali BARIN
2022-11-30 02:11:30 +01:00
parent 82e3b40e7c
commit b5436fe7fa

View File

@@ -41,6 +41,7 @@ const updateFlowStatus = async (
}; };
if (flow.active) { if (flow.active) {
// add the flow job in the queue.
flow = await flow.$query().patchAndFetch({ flow = await flow.$query().patchAndFetch({
published_at: new Date().toISOString(), published_at: new Date().toISOString(),
}); });
@@ -51,6 +52,7 @@ const updateFlowStatus = async (
jobName, jobName,
{ flowId: flow.id }, { flowId: flow.id },
{ {
// do not repeat webhook job for immediate webhook registration
repeat: trigger.type === 'webhook' ? null : repeatOptions, repeat: trigger.type === 'webhook' ? null : repeatOptions,
jobId: flow.id, jobId: flow.id,
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS, removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
@@ -58,6 +60,7 @@ const updateFlowStatus = async (
} }
); );
} else if (!flow.active && trigger.type === 'webhook') { } else if (!flow.active && trigger.type === 'webhook') {
// unregister webhook from the application
const $ = await globalVariable({ const $ = await globalVariable({
flow, flow,
connection: await triggerStep.$relatedQuery('connection'), connection: await triggerStep.$relatedQuery('connection'),
@@ -68,6 +71,7 @@ const updateFlowStatus = async (
await trigger.unregisterHook($); await trigger.unregisterHook($);
} else { } else {
// remove the job out of the queue
const repeatableJobs = await flowQueue.getRepeatableJobs(); const repeatableJobs = await flowQueue.getRepeatableJobs();
const job = repeatableJobs.find((job) => job.id === flow.id); const job = repeatableJobs.find((job) => job.id === flow.id);