Model/repositories/epc
Khalim Conn-Kowlessar 8685f8ba3a perf(repos): bulk get_many / get_for_properties — batch reads, not N round-trips (#1138)
Final slice of ADR-0012: collapse the per-property read round-trips a batch
made (Baseline hydrated ~8 queries x 30 properties one at a time) into a
handful of per-table IN queries.

- EpcPostgresRepository: extracted a shared `_compose(rows)` from `get` (the
  windows + floor-dim fetches are now passed in, not fetched inline), so both
  `get` and the new `get_for_properties(property_ids)` build EpcPropertyData
  from pre-fetched rows. `get_for_properties` fetches each child table once
  (`WHERE epc_property_id IN ...`), groups in memory, and composes — load-whole
  per ADR-0002.
- PropertyRepository.get_many(property_ids) -> Properties: one query for the
  property rows + one bulk EPC hydration, composed in input order.
- BaselineOrchestrator / IngestionOrchestrator read the batch via get_many
  instead of N x get.
- Ports + fakes gain the bulk methods.

The #1129 round-trip fidelity test stays green (the compose extraction is
behaviour-preserving). New tests: bulk hydration correctness + round-trips are
constant w.r.t. batch size (one-per-table, proven by query count). 123 pass;
pyright strict clean; AAA.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 10:33:24 +00:00
..
__init__.py feat(epc): EPC persistence round-trip fidelity + JSONB code columns (Slice 1 #1129) 2026-05-30 19:26:18 +00:00
epc_postgres_repository.py perf(repos): bulk get_many / get_for_properties — batch reads, not N round-trips (#1138) 2026-05-31 10:33:24 +00:00
epc_repository.py perf(repos): bulk get_many / get_for_properties — batch reads, not N round-trips (#1138) 2026-05-31 10:33:24 +00:00