perf(doctor): fetch-join specialties in clinic doctor list (H6)
findByClinicWithFilters left-joined specialties only for filtering, so toListArray() lazy-loaded them per doctor (N+1). addSelect them and switch the result fetch to Paginator(fetchJoinCollection: true) so LIMIT still paginates by doctor. Test infra: ApiTestCase::countQueries() (via doctrine.debug_data_holder). Regression: tests/Doctor/ClinicDoctorListNPlusOneTest asserts the query count does not grow with doctor count (4→10 without the fix). Also relaxed AppointmentExpiryServiceTest's exact-count assertion (it counts all stale pendings in the shared db_test, which accumulates) — logged test-isolation debt as E6. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -71,4 +71,17 @@ abstract class ApiTestCase extends WebTestCase
|
||||
{
|
||||
return $this->client->getResponse()->getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the SQL queries executed while running $fn. Used to assert that a
|
||||
* list endpoint's query count does not grow with the number of rows (N+1).
|
||||
*/
|
||||
protected function countQueries(callable $fn): int
|
||||
{
|
||||
$holder = static::getContainer()->get('doctrine.debug_data_holder');
|
||||
$holder->reset();
|
||||
$fn();
|
||||
|
||||
return array_sum(array_map('count', $holder->getData()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user