Skip to content

Open-source status page, incident response and uptime monitoring

🕛 Schedule next job (#1187)

Thibault Le Ouay204ebf043e7b
diff --git a/apps/workflows/src/cron/index.ts b/apps/workflows/src/cron/index.ts
index 11b6c073c..d589d469b 100644
--- a/apps/workflows/src/cron/index.ts
+++ b/apps/workflows/src/cron/index.ts
@@ -75,7 +75,7 @@ app.get("/monitors/:step", async (c) => {
switch (schema.data) {
case "14days":
// We send the first email
- await Step14Days(Number(userId));
+ await Step14Days(Number(userId), Number(initialRun));
break;
case "3days":
await Step3Days(Number(userId), Number(initialRun));
diff --git a/apps/workflows/src/cron/monitor.ts b/apps/workflows/src/cron/monitor.ts
index 9294fc833..1692e3224 100644
--- a/apps/workflows/src/cron/monitor.ts
+++ b/apps/workflows/src/cron/monitor.ts
@@ -186,7 +186,7 @@ async function workflowInit({
console.log(`user workflow started for ${user.userId}`);
}
-export async function Step14Days(userId: number) {
+export async function Step14Days(userId: number, workFlowRunTimestamp: number) {
const user = await getUser(userId);
// Send email saying we are going to pause the monitors
@@ -206,6 +206,14 @@ export async function Step14Days(userId: number) {
deactivateAt: new Date(new Date().setDate(new Date().getDate() + 14)),
}),
});
+
+ await CreateTask({
+ parent,
+ client: client,
+ step: "3days",
+ userId: user.id,
+ initialRun: workFlowRunTimestamp,
+ });
}
}