feat: ordering for getters

This commit is contained in:
2025-08-22 21:58:39 +04:00
parent 5e20da8356
commit c5e4dea52c
4 changed files with 14 additions and 7 deletions

View File

@ -11,8 +11,10 @@ from schemas.board import UpdateBoardSchema, CreateBoardSchema
class BoardRepository(BaseRepository): class BoardRepository(BaseRepository):
async def get_all(self, project_id: int) -> list[Board]: async def get_all(self, project_id: int) -> list[Board]:
stmt = select(Board).where( stmt = (
Board.is_deleted.is_(False), Board.project_id == project_id select(Board)
.where(Board.is_deleted.is_(False), Board.project_id == project_id)
.order_by(Board.lexorank)
) )
result = await self.session.execute(stmt) result = await self.session.execute(stmt)
return list(result.scalars().all()) return list(result.scalars().all())

View File

@ -9,7 +9,11 @@ from schemas.deal import UpdateDealSchema
class DealRepository(BaseRepository): class DealRepository(BaseRepository):
async def get_all(self, board_id: int) -> list[Deal]: async def get_all(self, board_id: int) -> list[Deal]:
stmt = select(Deal).where(Deal.is_deleted.is_(False), Deal.board_id == board_id) stmt = (
select(Deal)
.where(Deal.is_deleted.is_(False), Deal.board_id == board_id)
.order_by(Deal.lexorank)
)
result = await self.session.execute(stmt) result = await self.session.execute(stmt)
return list(result.scalars().all()) return list(result.scalars().all())

View File

@ -11,7 +11,7 @@ from schemas.project import CreateProjectSchema, UpdateProjectSchema
class ProjectRepository(BaseRepository): class ProjectRepository(BaseRepository):
async def get_all(self) -> list[Project]: async def get_all(self) -> list[Project]:
stmt = select(Project).where(Project.is_deleted.is_(False)) stmt = select(Project).where(Project.is_deleted.is_(False)).order_by(Project.id)
result = await self.session.execute(stmt) result = await self.session.execute(stmt)
return list(result.scalars().all()) return list(result.scalars().all())

View File

@ -1,4 +1,3 @@
from datetime import datetime
from typing import Optional from typing import Optional
from sqlalchemy import select, func from sqlalchemy import select, func
@ -10,8 +9,10 @@ from schemas.status import UpdateStatusSchema, CreateStatusSchema
class StatusRepository(BaseRepository): class StatusRepository(BaseRepository):
async def get_all(self, board_id: int) -> list[Status]: async def get_all(self, board_id: int) -> list[Status]:
stmt = select(Status).where( stmt = (
Status.is_deleted.is_(False), Status.board_id == board_id select(Status)
.where(Status.is_deleted.is_(False), Status.board_id == board_id)
.order_by(Status.lexorank)
) )
result = await self.session.execute(stmt) result = await self.session.execute(stmt)
return list(result.scalars().all()) return list(result.scalars().all())