Making scope filter by product id

This commit is contained in:
Ian Roddis committed 2026-08-11 13:11:15 -03:00
1 parent 6d7c5c5604
commit 2318a6daeb
4 files changed
+36 -5

No files matched your search

+11 -2
View File
@@ -1,4 +1,4 @@
from sqlalchemy import distinct, select
from sqlalchemy import distinct, or_, select
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.associations import augmented_part_imported_parts
@@ -89,10 +89,19 @@ async def list_filtered(
direction: str = "asc",
skip: int = 0,
limit: int = 100,
match_sku: bool = False,
) -> list[AugmentedPart]:
q = select(AugmentedPart)
if description.strip():
q = q.where(AugmentedPart.description.ilike(f"%{description.strip()}%"))
term = f"%{description.strip()}%"
if match_sku:
q = q.where(
or_(
AugmentedPart.description.ilike(term), AugmentedPart.sku.ilike(term)
)
)
else:
q = q.where(AugmentedPart.description.ilike(term))
if colour_id is not None:
q = q.where(AugmentedPart.colour_id == colour_id)
if manufacturer_id is not None: