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 backfill-workspace-groups-limit.ts

Kiran Kea09de4fe896
diff --git a/apps/web/scripts/partners/backfill-workspace-groups-limit.ts b/apps/web/scripts/partners/backfill-workspace-groups-limit.ts
index cf4f11f767..4b47f3f9b5 100644
--- a/apps/web/scripts/partners/backfill-workspace-groups-limit.ts
+++ b/apps/web/scripts/partners/backfill-workspace-groups-limit.ts
@@ -27,20 +27,30 @@ async function main() {
console.table(workspaces);
console.log(`Found ${workspaces.length} workspaces to update.`);
- await Promise.allSettled(
- workspaces.map((workspace) => {
- const plan = getCurrentPlan(workspace.plan);
+ // Batch update the workspaces
+ const groupedByPlan = workspaces.reduce(
+ (acc, ws) => {
+ if (!acc[ws.plan]) acc[ws.plan] = [];
+ acc[ws.plan].push(ws.id);
+ return acc;
+ },
+ {} as Record<string, string[]>,
+ );
- return prisma.project.update({
- where: {
- id: workspace.id,
- },
- data: {
- groupsLimit: plan.limits.groups!,
+ console.log(groupedByPlan);
+
+ for (const [plan, workspaceIds] of Object.entries(groupedByPlan)) {
+ await prisma.project.updateMany({
+ where: {
+ id: {
+ in: workspaceIds,
},
- });
- }),
- );
+ },
+ data: {
+ groupsLimit: getCurrentPlan(plan).limits.groups!,
+ },
+ });
+ }
}
main();