Making scope filter by product id
This commit is contained in:
1 parent
6d7c5c5604
commit
2318a6daeb
4 files changed
+36
-5
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user