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.

Document single-workspace bulkDeleteLinks and delete network invite links per enrollment.

Kiran Kb6dee912af9d
diff --git a/apps/web/lib/api/links/bulk-delete-links.ts b/apps/web/lib/api/links/bulk-delete-links.ts
index bb91054d08..1a16a84e5c 100644
--- a/apps/web/lib/api/links/bulk-delete-links.ts
+++ b/apps/web/lib/api/links/bulk-delete-links.ts
@@ -16,6 +16,8 @@ const DELETE_LINKS_BATCH_SIZE = 100;
* 3. Run side effects (Redis / Tinybird / R2)
*
* Processes links in batches of DELETE_LINKS_BATCH_SIZE.
+ * Callers must pass links from a single workspace — totalLinks is
+ * decremented on links[0].projectId for the whole batch.
*/
export async function bulkDeleteLinks(
links: ExpandedLink[],
diff --git a/apps/web/scripts/programs/delete-network-invites.ts b/apps/web/scripts/programs/delete-network-invites.ts
index 39f9e4ce27..f7512149e3 100644
--- a/apps/web/scripts/programs/delete-network-invites.ts
+++ b/apps/web/scripts/programs/delete-network-invites.ts
@@ -34,11 +34,14 @@ async function main() {
})),
);
- const linksToDelete = discoveredPartners.flatMap(
- ({ programEnrollment }) => programEnrollment?.links ?? [],
- );
+ // Delete per enrollment so each bulkDeleteLinks call stays single-workspace
+ for (const { programEnrollment } of discoveredPartners) {
+ const links = programEnrollment?.links ?? [];
- await bulkDeleteLinks(linksToDelete);
+ if (links.length > 0) {
+ await bulkDeleteLinks(links);
+ }
+ }
const res2 = await prisma.$transaction([
prisma.discoveredPartner.deleteMany({