Identify and eliminate duplicate or inefficient operations that waste computational resources. Common patterns to watch for include:
Example of problematic code:
// Bad: Duplicate expensive calls
await getAvailableSlots({...}); // calls getUserAvailability internally
await ensureAvailableUsers({...}); // also calls getUserAvailability internally
// Bad: Inefficient database query
const allSubscriptions = await prisma.calendarSubscription.findMany({
select: { selectedCalendarId: true },
});
const excludeIds = allSubscriptions.map((sub) => sub.selectedCalendarId);
// Good: Single call or proper WHERE clause
await ensureAvailableUsers({users: [...users, ...guests]});
// Good: Efficient database query
const selectedCalendars = await prisma.selectedCalendar.findMany({
where: { calendarSubscriptionId: null }
});
Before implementing functionality, analyze the call flow to identify potential redundant operations and consolidate them into single, efficient calls.
Enter the URL of a public GitHub repository