Adding pagination

This commit is contained in:
Ian Roddis committed 2026-07-02 14:48:21 -03:00
1 parent a50fccd56d
commit e923250177
8 files changed
+269 -46

No files matched your search

+9
View File
@@ -51,6 +51,15 @@ async def count(db: AsyncSession) -> int:
return result.scalar_one()
async def count_filtered(db: AsyncSession, description: str = "") -> int:
from sqlalchemy import func
q = select(func.count()).select_from(ImportedPart)
if description.strip():
q = q.where(ImportedPart.Description.ilike(f"%{description.strip()}%"))
result = await db.execute(q)
return result.scalar_one()
async def delete(db: AsyncSession, part: ImportedPart) -> None:
await db.delete(part)
await db.commit()