-
Notifications
You must be signed in to change notification settings - Fork 0
Automated Test: sms-retry-enhanced #372
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({ | ||||||||||||||||||||||||||||||||||||||
| where: { | ||||||||||||||||||||||||||||||||||||||
| id: reminder.id, | ||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||
| retryCount: reminder.retryCount + 1, | ||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+178
to
+186
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. 🧩 Analysis chain🏁 Script executed: fd scheduleSMSReminders.tsRepository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 206 🏁 Script executed: wc -l packages/features/ee/workflows/api/scheduleSMSReminders.tsRepository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 152 🏁 Script executed: cat -n packages/features/ee/workflows/api/scheduleSMSReminders.ts | sed -n '170,200p'Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 1028 🏁 Script executed: cat -n packages/features/ee/workflows/api/scheduleSMSReminders.ts | head -100Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 4333 🏁 Script executed: cat -n packages/features/ee/workflows/api/scheduleSMSReminders.ts | sed -n '1,70p' | tail -20Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 677 🏁 Script executed: rg "increment:" packages/features/ee/workflows/ -A 2 -B 2Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 508 🏁 Script executed: rg "retryCount.*increment" --type ts --type tsxRepository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 117 🏁 Script executed: rg "increment:" -t ts -A 1 -B 1 | head -50Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 1680 🏁 Script executed: sed -n '1,50p' packages/features/tasker/repository.ts | grep -A 10 "increment"Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 72 🏁 Script executed: rg -n "attempts.*increment" packages/features/tasker/repository.ts -B 5 -A 5Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 520 🏁 Script executed: cat -n packages/features/ee/workflows/api/scheduleSMSReminders.ts | sed -n '160,200p'Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 1313 Replace
This occurs at lines 184 and 195. Suggested fix data: {
- retryCount: reminder.retryCount + 1,
+ retryCount: { increment: 1 },
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } 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; |
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.
Scope retry cleanup to SMS and unscheduled reminders only.
The new
ORbranch (retryCount > 1) is not constrained tomethod: SMS, and also deletes scheduled reminders with retries, which can remove unrelated/valid reminders. Consider scoping the delete to SMS and unscheduled failed retries.🔧 Suggested fix
🤖 Prompt for AI Agents