Repository navigation
SMS workflow reminder retry count tracking #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sms-retry-base
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,10 +28,19 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { | |
| //delete all scheduled sms reminders where scheduled date is past current date | ||
| await prisma.workflowReminder.deleteMany({ | ||
| where: { | ||
| method: WorkflowMethods.SMS, | ||
| scheduledDate: { | ||
| lte: dayjs().toISOString(), | ||
| }, | ||
| OR: [ | ||
| { | ||
| method: WorkflowMethods.SMS, | ||
| scheduledDate: { | ||
| lte: dayjs().toISOString(), | ||
| }, | ||
| }, | ||
| { | ||
| retryCount: { | ||
| gt: 1, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
|
|
@@ -44,8 +53,11 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { | |
| lte: dayjs().add(7, "day").toISOString(), | ||
| }, | ||
| }, | ||
| select, | ||
| })) as PartialWorkflowReminder[]; | ||
| select: { | ||
| ...select, | ||
| retryCount: true, | ||
| }, | ||
| })) as (PartialWorkflowReminder & { retryCount: number })[]; | ||
|
|
||
| if (!unscheduledReminders.length) { | ||
| res.json({ ok: true }); | ||
|
|
@@ -163,9 +175,26 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { | |
| referenceId: scheduledSMS.sid, | ||
| }, | ||
| }); | ||
| } else { | ||
| await prisma.workflowReminder.update({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The Prompt for AI agents |
||
| where: { | ||
| id: reminder.id, | ||
| }, | ||
| data: { | ||
| retryCount: reminder.retryCount + 1, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| await prisma.workflowReminder.update({ | ||
| where: { | ||
| id: reminder.id, | ||
| }, | ||
| data: { | ||
| retryCount: reminder.retryCount + 1, | ||
| }, | ||
| }); | ||
| console.log(`Error scheduling SMS with error ${error}`); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "WorkflowReminder" ADD COLUMN "retryCount" INTEGER NOT NULL DEFAULT 0; |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Bug: The
retryCount > 1deletion condition is missing themethod: WorkflowMethods.SMSfilter. As written, this will delete all workflow reminders (EMAIL, WHATSAPP, etc.) that haveretryCount > 1, not just SMS ones. The first OR branch correctly scopes to SMS, but the second branch applies globally.Prompt for AI agents