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.

E2E cleanup: delete discount codes by linkId via Prisma

Kiran K6a69a47d3686
diff --git a/apps/web/app/(ee)/api/cron/cleanup/e2e-tests/route.ts b/apps/web/app/(ee)/api/cron/cleanup/e2e-tests/route.ts
index 1f4a4bce5a..e841040936 100644
--- a/apps/web/app/(ee)/api/cron/cleanup/e2e-tests/route.ts
+++ b/apps/web/app/(ee)/api/cron/cleanup/e2e-tests/route.ts
@@ -1,4 +1,3 @@
-import { deleteDiscountCodes } from "@/lib/api/discounts/delete-discount-code";
import { markDomainAsDeleted } from "@/lib/api/domains/mark-domain-deleted";
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { bulkDeleteLinks } from "@/lib/api/links/bulk-delete-links";
@@ -100,12 +99,20 @@ export async function POST(req: Request) {
// Delete the links
if (links.length > 0) {
- await deleteDiscountCodes(links.flatMap((link) => link.discountCode));
+ const linkIds = links.map((link) => link.id);
+
+ await prisma.discountCode.deleteMany({
+ where: {
+ linkId: {
+ in: linkIds,
+ },
+ },
+ });
await prisma.link.deleteMany({
where: {
id: {
- in: links.map((link) => link.id),
+ in: linkIds,
},
},
});