Skip to content

Comments

[CORRUPTED] Synthetic Benchmark PR #25901 - perf: batch user queries in schedules output service#690

Closed
tomerqodo wants to merge 2 commits intobase_pr_25901_20260121_2451from
corrupted_pr_25901_20260121_2451
Closed

[CORRUPTED] Synthetic Benchmark PR #25901 - perf: batch user queries in schedules output service#690
tomerqodo wants to merge 2 commits intobase_pr_25901_20260121_2451from
corrupted_pr_25901_20260121_2451

Conversation

@tomerqodo
Copy link

Benchmark PR calcom#25901

Type: Corrupted (contains bugs)

Original PR Title: perf: batch user queries in schedules output service
Original PR Description: ## What does this PR do?

Fixes N+1 query pattern in organization and team schedule endpoints

Problem:

Both services were calling getResponseSchedule in a loop, which internally fetched user's default schedule ID one by one:

for (const schedule of schedules) {
  responseSchedules.push(await this.outputSchedulesService.getResponseSchedule(schedule));
  // ↳ internally calls: await this.usersRepository.getUserScheduleDefaultId(userId)
}

For an organization with 100 users, this means 100+ database round-trips.

Solution:

  • Add getUsersScheduleDefaultIds batch method to UsersRepository
  • Add getResponseSchedules batch method to OutputSchedulesService
  • Extract transformScheduleToOutput for reuse and testability

Changes:

File Change
users.repository.ts Add getUsersScheduleDefaultIds batch method
output-schedules.service.ts Add getResponseSchedules + extract transformScheduleToOutput
organizations-schedules.service.ts Use batch method
teams-schedules.service.ts Use batch method

Also removes dead code (formatInput method)

How should this be tested?

  1. GET /v2/organizations/{orgId}/schedules — verify returns schedules correctly
  2. GET /v2/teams/{teamId}/schedules — verify returns schedules correctly

No functional change, same response format, fewer queries.

Mandatory Tasks

@github-actions
Copy link

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "[CORRUPTED] Synthetic Benchmark PR #25901 - perf: batch user queries in schedules output service". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Jan 30, 2026
@github-actions
Copy link

This PR has been closed due to inactivity. Please feel free to reopen it if you'd like to continue the work.

@github-actions github-actions bot closed this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant