The plan repository reports which properties already have a default plan 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-07 16:11:32 +00:00
parent 015db4275b
commit 371240c885

View file

@ -3,7 +3,7 @@ from __future__ import annotations
from typing import Any
from sqlalchemy import insert as _sa_insert
from sqlmodel import Session, col, update
from sqlmodel import Session, col, select, update
from domain.modelling.plan import Plan
from infrastructure.postgres.modelling import PlanModel, RecommendationModel
@ -46,7 +46,15 @@ class PlanPostgresRepository(PlanRepository):
)[0]
def property_ids_with_default_plans(self, property_ids: list[int]) -> set[int]:
raise NotImplementedError
rows = self._session.exec(
select(col(PlanModel.property_id))
.distinct()
.where(
col(PlanModel.property_id).in_(property_ids),
col(PlanModel.is_default).is_(True),
)
).all()
return {int(row) for row in rows}
def save_batch(self, requests: list[PlanSaveRequest]) -> list[int]:
"""Persist all Plans in three statements regardless of batch size.