feat(doctor): expose city/state in public doctor list
The public doctor list had no location field, so multi-domain consumers could not tell which city domain owns a doctor. nobat724_front's sitemap worked around this by fetching the list once per city (35 sweeps) and subtracting, costing ~13s to build the root sitemap. Location is resolved in bulk by DoctorRepository::findLocationsByDoctors using the same rule the city_id/state_id filter applies: the doctor's own address first, falling back to the address of a clinic they belong to. Without the clinic fallback a doctor could match city_id=X yet report no city, which would break the sitemap's per-domain partitioning. city/state are arrays with at most one entry, matching the shape already used by the doctor detail response and the clinic list. A doctor with no address reports [] rather than null. Multi-location doctors get a single primary city, mirroring the canonical rule on the public site. Also surface the applied page size as meta.limit. Repositories silently clamp limit to 50, which previously made clients believe pagination had ended early — this is what truncated the sitemap to 50 doctors. The clinic doctor-list endpoint gets the same location data so both endpoints agree. Location resolution costs at most 2 queries regardless of page size, asserted directly against the repository rather than through the endpoint, since the endpoint carries a pre-existing specialties N+1 in findWithFilters that is unrelated to this change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -260,8 +260,16 @@ class DoctorController extends BaseController
|
||||
$scheduleMap[$schedule->getDoctor()->getId()][] = $schedule;
|
||||
}
|
||||
|
||||
$locationMap = $this->doctorRepo->findLocationsByDoctors($result['items']);
|
||||
|
||||
return $this->paginated(
|
||||
array_map(fn(Doctor $d) => $d->toListArray($scheduleMap[$d->getId()] ?? []), $result['items']),
|
||||
array_map(
|
||||
fn(Doctor $d) => $d->toListArray(
|
||||
$scheduleMap[$d->getId()] ?? [],
|
||||
$locationMap[$d->getId()] ?? null
|
||||
),
|
||||
$result['items']
|
||||
),
|
||||
$result['total'],
|
||||
$result['page'],
|
||||
$result['limit']
|
||||
|
||||
Reference in New Issue
Block a user