mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
No filters resolves the whole portfolio minus deletions 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
84fb9884d6
commit
3836729f92
1 changed files with 16 additions and 2 deletions
|
|
@ -10,7 +10,9 @@ from dataclasses import dataclass
|
|||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from sqlmodel import Session
|
||||
from sqlmodel import Session, col, select
|
||||
|
||||
from infrastructure.postgres.property_table import PropertyRow
|
||||
|
||||
|
||||
class PropertyGroupFilters(BaseModel):
|
||||
|
|
@ -41,4 +43,16 @@ def resolve_filtered_property_ids(
|
|||
portfolio's rows with ``marked_for_deletion = false``; property_type /
|
||||
built_form resolve override → lodged EPC → predicted EPC → legacy columns
|
||||
→ "Unknown"."""
|
||||
raise NotImplementedError
|
||||
rows = session.exec(
|
||||
select(PropertyRow)
|
||||
.where(PropertyRow.portfolio_id == portfolio_id)
|
||||
# IS NOT TRUE rather than == False: the FE schema defaults the flag,
|
||||
# but a NULL must never silently exclude a property.
|
||||
.where(col(PropertyRow.marked_for_deletion).isnot(True))
|
||||
.order_by(col(PropertyRow.id))
|
||||
).all()
|
||||
return [
|
||||
FilteredProperty(property_id=row.id, postcode=row.postcode)
|
||||
for row in rows
|
||||
if row.id is not None
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue