perf: batch user queries in schedules output service#25901
Merged
keithwillcode merged 6 commits intomainfrom Jan 13, 2026
Merged
perf: batch user queries in schedules output service#25901keithwillcode merged 6 commits intomainfrom
keithwillcode merged 6 commits intomainfrom
Conversation
Replace N sequential queries with single batch query for fetching user default schedule IDs Changes: - Add getUsersScheduleDefaultIds batch method to UsersRepository - Add getResponseSchedules batch method to OutputSchedulesService - Extract transformScheduleToOutput for reuse - Simplify OrganizationsSchedulesService and TeamsSchedulesService - Remove dead code (formatInput no-op method) Reduces database round-trips from O(n) to O(1) for schedule lookups
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes N+1 query pattern in organization and team schedule endpoints
Problem:
Both services were calling
getResponseSchedulein a loop, which internally fetched user's default schedule ID one by one:For an organization with 100 users, this means 100+ database round-trips.
Solution:
getUsersScheduleDefaultIdsbatch method toUsersRepositorygetResponseSchedulesbatch method toOutputSchedulesServicetransformScheduleToOutputfor reuse and testabilityChanges:
users.repository.tsgetUsersScheduleDefaultIdsbatch methodoutput-schedules.service.tsgetResponseSchedules+ extracttransformScheduleToOutputorganizations-schedules.service.tsteams-schedules.service.tsAlso removes dead code (
formatInputmethod)How should this be tested?
GET /v2/organizations/{orgId}/schedules— verify returns schedules correctlyGET /v2/teams/{teamId}/schedules— verify returns schedules correctlyNo functional change, same response format, fewer queries.
Mandatory Tasks