From 281b72cb37e6c53c7ac464decdaa3c4459b6cb7f Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Tue, 23 Sep 2025 11:07:12 -0700 Subject: [PATCH 1/2] submit button state --- .../admin-dashboard/app/routes/_dashboard.students.remove.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx b/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx index e89eede82..c73b1e5d3 100644 --- a/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx +++ b/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx @@ -126,9 +126,7 @@ export default function RemoveMembersPage() { - + Remove From ff7775460d560f94d68745c95967f3328246f97b Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Tue, 23 Sep 2025 11:23:49 -0700 Subject: [PATCH 2/2] batch the removals --- .../app/routes/_dashboard.students.remove.tsx | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx b/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx index c73b1e5d3..5fb59a914 100644 --- a/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx +++ b/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx @@ -20,6 +20,7 @@ import { validateForm, } from '@oyster/ui'; import { Callout } from '@oyster/ui/callout'; +import { splitArray } from '@oyster/utils'; import { Route } from '@/shared/constants'; import { @@ -66,23 +67,31 @@ export async function action({ request }: ActionFunctionArgs) { } async function removeMembers(ids: string[]): Promise { - const students = await db - .deleteFrom('students') - .where('id', 'in', ids) - .returning(['airtableId', 'email', 'firstName', 'slackId']) - .execute(); - - for (const student of students) { - job('student.removed', { - airtableId: student.airtableId as string, - email: student.email, - firstName: student.firstName, - sendViolationEmail: false, - slackId: student.slackId, - }); + const batches = splitArray(ids, 10); + + let count = 0; + + for (const batch of batches) { + const students = await db + .deleteFrom('students') + .where('id', 'in', batch) + .returning(['airtableId', 'email', 'firstName', 'slackId']) + .execute(); + + for (const student of students) { + job('student.removed', { + airtableId: student.airtableId as string, + email: student.email, + firstName: student.firstName, + sendViolationEmail: false, + slackId: student.slackId, + }); + } + + count += students.length; } - return students.length; + return count; } export default function RemoveMembersPage() {