from sqlalchemy.orm import selectinload from models import Board from repositories.base import BaseRepository from repositories.mixins import * from schemas.board import UpdateBoardSchema, CreateBoardSchema class BoardRepository( BaseRepository, RepGetAllMixin[Board], RepDeleteMixin[Board], RepCreateMixin[Board, CreateBoardSchema], RepUpdateMixin[Board, UpdateBoardSchema], RepGetByIdMixin[Board], ): entity_class = Board def _process_get_all_stmt_with_args(self, stmt: Select, *args) -> Select: project_id = args[0] return stmt.where(Board.project_id == project_id).order_by(Board.lexorank) def _process_get_by_id_stmt(self, stmt: Select) -> Select: return stmt.options(selectinload(Board.deals)) async def update(self, board: Board, data: UpdateBoardSchema) -> Board: return await self._apply_update_data_to_model(board, data, True)