Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion app/api/assignments/[id]/nodes/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ export async function POST(
}

const existingNodeIds = existingNodes?.map((n) => n.id) || [];
const missingNodes = node_ids.filter((id) => !existingNodeIds.includes(id));
// Optimization: Use Set for O(1) lookups instead of Array.includes which is O(N)
const existingNodeIdsSet = new Set(existingNodeIds);
const missingNodes = node_ids.filter((id) => !existingNodeIdsSet.has(id));

if (missingNodes.length > 0) {
return NextResponse.json(
Expand Down
4 changes: 3 additions & 1 deletion app/api/classrooms/[id]/grading/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ export async function GET(

// Get additional profiles for members not in submissions
const classroomUserIds = classroomMembers.map(m => m.user_id);
const missingUserIds = classroomUserIds.filter(id => !submissionUserIds.includes(id));
// Optimization: Use Set for O(1) lookups instead of Array.includes which is O(N)
const submissionUserIdsSet = new Set(submissionUserIds);
const missingUserIds = classroomUserIds.filter(id => !submissionUserIdsSet.has(id));

let additionalProfiles: any[] = [];
if (missingUserIds.length > 0) {
Expand Down
4 changes: 3 additions & 1 deletion components/teams/StudentTeamDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export function StudentTeamDashboard({

// Find available teams (teams user is NOT in)
const userTeamIds = userTeams.map((t) => t.id);
const availableTeams = allTeams.filter((t) => !userTeamIds.includes(t.id));
// Optimization: Use Set for O(1) lookups instead of Array.includes which is O(N)
const userTeamIdsSet = new Set(userTeamIds);
const availableTeams = allTeams.filter((t) => !userTeamIdsSet.has(t.id));

// Get teams with open spots
const teamsWithOpenSpots = availableTeams.filter(
Expand Down