Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update route.ts

Kiran Kc33043eaf3c3
diff --git a/apps/web/app/(ee)/api/cron/discount-codes/create/queue-batches/route.ts b/apps/web/app/(ee)/api/cron/discount-codes/create/queue-batches/route.ts
index eb9f3f349c..4b6f46290b 100644
--- a/apps/web/app/(ee)/api/cron/discount-codes/create/queue-batches/route.ts
+++ b/apps/web/app/(ee)/api/cron/discount-codes/create/queue-batches/route.ts
@@ -100,16 +100,18 @@ export const POST = withCron(async ({ rawBody }) => {
const links = programEnrollments.flatMap(({ links }) => links);
- await enqueueBatchJobs(
- links.map((link) => ({
- queueName: "create-discount-code",
- url: `${APP_DOMAIN_WITH_NGROK}/api/cron/discount-codes/create`,
- deduplicationId: `${discountId}-${link.id}-1`,
- body: {
- linkId: link.id,
- },
- })),
- );
+ if (links.length > 0) {
+ await enqueueBatchJobs(
+ links.map((link) => ({
+ queueName: "create-discount-code",
+ url: `${APP_DOMAIN_WITH_NGROK}/api/cron/discount-codes/create`,
+ deduplicationId: `${discountId}-${link.id}-1`,
+ body: {
+ linkId: link.id,
+ },
+ })),
+ );
+ }
if (programEnrollments.length === CRON_BATCH_SIZE) {
const startingAfter = programEnrollments[programEnrollments.length - 1].id;