diff --git a/repositories/deal.py b/repositories/deal.py index 27a7f5c..5ea36ac 100644 --- a/repositories/deal.py +++ b/repositories/deal.py @@ -1,7 +1,6 @@ from typing import Optional from sqlalchemy import select -from sqlalchemy.orm import joinedload from models import Deal, CardStatusHistory, Board from repositories.base import BaseRepository @@ -23,11 +22,7 @@ class DealRepository(BaseRepository): id: Optional[int], name: Optional[str], ) -> tuple[list[Deal], int]: - stmt = ( - select(Deal) - .options(joinedload(Deal.status), joinedload(Deal.board)) - .where(Deal.is_deleted.is_(False)) - ) + stmt = select(Deal).where(Deal.is_deleted.is_(False)) if id: stmt = stmt.where(Deal.id == id) @@ -54,11 +49,7 @@ class DealRepository(BaseRepository): return list(result.scalars().all()), total_items async def get_by_id(self, deal_id: int) -> Optional[Deal]: - stmt = ( - select(Deal) - .options(joinedload(Deal.status), joinedload(Deal.board)) - .where(Deal.id == deal_id, Deal.is_deleted.is_(False)) - ) + stmt = select(Deal).where(Deal.id == deal_id, Deal.is_deleted.is_(False)) result = await self.session.execute(stmt) return result.scalar_one_or_none() @@ -67,8 +58,7 @@ class DealRepository(BaseRepository): self.session.add(deal) await self.session.commit() await self.session.refresh(deal) - print(deal.id) - return await self.get_by_id(deal.id) + return deal async def update(self, deal: Deal, data: UpdateDealSchema) -> Deal: deal.lexorank = data.lexorank if data.lexorank else deal.lexorank diff --git a/schemas/deal.py b/schemas/deal.py index cc9f3df..c79d253 100644 --- a/schemas/deal.py +++ b/schemas/deal.py @@ -2,8 +2,6 @@ from datetime import datetime from typing import Optional from schemas.base import BaseSchema, BaseResponse, PaginationInfoSchema -from schemas.board import BoardSchema -from schemas.status import StatusSchema # region Entities @@ -13,8 +11,8 @@ class DealSchema(BaseSchema): id: int name: str lexorank: str - status: StatusSchema - board: BoardSchema + status_id: int + board_id: int created_at: datetime