mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
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>
25 lines
840 B
Python
25 lines
840 B
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from domain.property.properties import Properties
|
|
from domain.property.property import Property
|
|
|
|
|
|
class PropertyRepository(ABC):
|
|
"""Loads and saves the Property aggregate.
|
|
|
|
Composes the aggregate whole from the FE-owned ``property`` identity row plus
|
|
its source-data slices (EPC today; Site Notes / enrichments as later slices
|
|
land). Aggregates load whole — never half a Property (ADR-0002).
|
|
"""
|
|
|
|
@abstractmethod
|
|
def get(self, property_id: int) -> Property: ...
|
|
|
|
@abstractmethod
|
|
def get_many(self, property_ids: list[int]) -> Properties:
|
|
"""Load a batch of Properties whole, in a handful of per-table queries
|
|
rather than one round-trip per property (ADR-0012). Order follows the
|
|
input ids."""
|
|
...
|