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 bulk-delete-links.ts

Steven Teya3c3b718fd98
diff --git a/apps/web/lib/api/links/bulk-delete-links.ts b/apps/web/lib/api/links/bulk-delete-links.ts
index 61f20bb37e..db2652e74f 100644
--- a/apps/web/lib/api/links/bulk-delete-links.ts
+++ b/apps/web/lib/api/links/bulk-delete-links.ts
@@ -1,4 +1,3 @@
-import { prisma } from "@/lib/prisma";
import { storage } from "@/lib/storage";
import { recordLink } from "@/lib/tinybird";
import { redis } from "@/lib/upstash";
@@ -23,12 +22,6 @@ export async function bulkDeleteLinks({
});
return await Promise.all([
- // Delete the images
- // TODO: How do we optimize this?
- links
- .filter((link) => link.image?.startsWith(`${R2_URL}/images/${link.id}`))
- .map((link) => storage.delete(link.image!.replace(`${R2_URL}/`, ""))),
-
// Delete the links from Redis
pipeline.exec(),
@@ -46,16 +39,10 @@ export async function bulkDeleteLinks({
})),
),
- // Decrement the workspace's links usage
- prisma.project.update({
- where: {
- id: workspaceId,
- },
- data: {
- linksUsage: {
- decrement: links.length,
- },
- },
- }),
+ // For links that have an image, delete the image from R2
+ // TODO: How do we optimize this?
+ links
+ .filter((link) => link.image?.startsWith(`${R2_URL}/images/${link.id}`))
+ .map((link) => storage.delete(link.image!.replace(`${R2_URL}/`, ""))),
]);
}