mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
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:
parent
015db4275b
commit
371240c885
1 changed files with 10 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue