mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Resolve a property's display address from its landlord_property_id 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
456d4dffe7
commit
0387f4a897
1 changed files with 10 additions and 3 deletions
|
|
@ -23,8 +23,15 @@ class LandlordAddressResolver:
|
|||
def __init__(
|
||||
self, session: Session, landlord_property_ids: Sequence[str]
|
||||
) -> None:
|
||||
self._session = session
|
||||
self._ids = list(landlord_property_ids)
|
||||
stmt = select(PropertyRow).where(
|
||||
col(PropertyRow.landlord_property_id).in_(list(landlord_property_ids))
|
||||
)
|
||||
rows = session.execute(stmt).scalars().all() # pyright: ignore[reportDeprecated]
|
||||
self._by_id: dict[str, str] = {
|
||||
row.landlord_property_id: row.address
|
||||
for row in rows
|
||||
if row.landlord_property_id is not None and row.address is not None
|
||||
}
|
||||
|
||||
def address_for(self, landlord_property_id: str) -> str:
|
||||
raise NotImplementedError
|
||||
return self._by_id.get(landlord_property_id, self._FALLBACK)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue