Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/api/assignments/[id]/enrollments/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export async function GET(
}

// Check if user is instructor/TA (can see all enrollments) or student (can see only their own)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const classroomData = assignment.classroom as any;
const membership = classroomData?.classroom_memberships?.[0];
const canViewAll =
Expand Down Expand Up @@ -201,10 +202,10 @@ export async function GET(
});

// Combine enrollment and user data
// ⚑ Bolt: Use Map for O(1) lookups instead of O(N) array.find() inside iterative methods
const userProfilesMap = new Map(userProfiles?.map(profile => [profile.user_id, profile]) || []);
const enrichedEnrollments = enrollments.map((enrollment) => {
const userProfile = userProfiles?.find(
(profile) => profile.user_id === enrollment.user_id
);
const userProfile = userProfilesMap.get(enrollment.user_id);
return {
...enrollment,
user: userProfile
Expand Down