The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Refactor discount code deletion logic
Kiran K81d5c9837c49
diff --git a/apps/web/app/(ee)/api/cron/discounts/delete-discount-code/route.ts b/apps/web/app/(ee)/api/cron/discounts/delete-discount-code/route.tsindex d2c2c2915f..b75927607b 100644--- a/apps/web/app/(ee)/api/cron/discounts/delete-discount-code/route.ts+++ b/apps/web/app/(ee)/api/cron/discounts/delete-discount-code/route.ts@@ -33,10 +33,6 @@ export async function POST(req: Request) {return logAndRespond(`Discount code ${discountCodeId} not found.`);}- if (discountCode.discountId) {- return logAndRespond(`Discount code ${discountCodeId} is not deleted.`);- }-const workspace = await prisma.project.findUniqueOrThrow({where: {defaultProgramId: discountCode.programId,diff --git a/apps/web/app/(ee)/api/cron/discounts/remap-discount-codes/route.ts b/apps/web/app/(ee)/api/cron/discounts/remap-discount-codes/route.tsindex 05cfce144a..82a1f78b86 100644--- a/apps/web/app/(ee)/api/cron/discounts/remap-discount-codes/route.ts+++ b/apps/web/app/(ee)/api/cron/discounts/remap-discount-codes/route.ts@@ -89,6 +89,7 @@ export async function POST(req: Request) {console.log({ discountCodesToUpdate, discountCodesToRemove });+ // Update the discount codes to use the new discountif (discountCodesToUpdate.length > 0) {await prisma.discountCode.updateMany({where: {@@ -102,6 +103,7 @@ export async function POST(req: Request) {});}+ // Remove the discount codes from the groupif (discountCodesToRemove.length > 0) {await Promise.allSettled(discountCodesToRemove.map((discountCodeId) =>