From bc4b8f9fe36470cce812112ba6785773667c4931 Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Tue, 23 Sep 2025 20:42:29 -0700 Subject: [PATCH 1/2] show error message --- .../app/routes/_dashboard.students.remove.tsx | 38 +++++++++++-------- 1 file changed, 23 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 5fb59a914..f7086c5f3 100644 --- a/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx +++ b/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/react-router'; import { type ActionFunctionArgs, data, @@ -53,17 +54,28 @@ export async function action({ request }: ActionFunctionArgs) { return data(result, { status: 400 }); } - const count = await removeMembers(result.data.memberIds); - - toast(session, { - message: `Removed ${count} members.`, - }); - - return redirect(Route['/students'], { - headers: { - 'Set-Cookie': await commitSession(session), - }, - }); + try { + const count = await removeMembers(result.data.memberIds); + + toast(session, { + message: `Removed ${count} members.`, + }); + + return redirect(Route['/students'], { + headers: { + 'Set-Cookie': await commitSession(session), + }, + }); + } catch (e) { + Sentry.captureException(e); + + return data( + { + error: `An error occurred while removing members: ${(e as Error).message}`, + }, + { status: 500 } + ); + } } async function removeMembers(ids: string[]): Promise { @@ -141,7 +153,3 @@ export default function RemoveMembersPage() { ); } - -export function ErrorBoundary() { - return <>; -} From 5d87b91347bdc096ee98959fe3b3952c4b140099 Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Tue, 23 Sep 2025 20:49:42 -0700 Subject: [PATCH 2/2] allow batches to continue --- .../app/routes/_dashboard.students.remove.tsx | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx b/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx index f7086c5f3..37d4511d2 100644 --- a/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx +++ b/apps/admin-dashboard/app/routes/_dashboard.students.remove.tsx @@ -54,28 +54,17 @@ export async function action({ request }: ActionFunctionArgs) { return data(result, { status: 400 }); } - try { - const count = await removeMembers(result.data.memberIds); - - toast(session, { - message: `Removed ${count} members.`, - }); - - return redirect(Route['/students'], { - headers: { - 'Set-Cookie': await commitSession(session), - }, - }); - } catch (e) { - Sentry.captureException(e); - - return data( - { - error: `An error occurred while removing members: ${(e as Error).message}`, - }, - { status: 500 } - ); - } + const count = await removeMembers(result.data.memberIds); + + toast(session, { + message: `Removed ${count} members.`, + }); + + return redirect(Route['/students'], { + headers: { + 'Set-Cookie': await commitSession(session), + }, + }); } async function removeMembers(ids: string[]): Promise { @@ -84,23 +73,27 @@ async function removeMembers(ids: string[]): Promise { 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, - }); + try { + 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; + } catch (e) { + Sentry.captureException(e); } - - count += students.length; } return count;