feat: search tackle catalog by name
This commit is contained in:
@@ -44,13 +44,18 @@ def _rig_missing_fields(rig: Rig) -> list[str]:
|
||||
def tackle_items(
|
||||
db: Db,
|
||||
category: str | None = Query(None, pattern="^(bait|lure|rod|reel|line|hook|rig|float|sinker|other)$"),
|
||||
q: str | None = None,
|
||||
brand: str | None = None,
|
||||
family: str | None = None,
|
||||
unlock_level: int | None = Query(None, ge=0),
|
||||
limit: int = Query(50, ge=1, le=100),
|
||||
offset: int = Query(0, ge=0),
|
||||
) -> PaginatedTackleItemOut:
|
||||
if q is not None and len(q) > 100:
|
||||
raise HTTPException(status_code=422, detail="search query is too long")
|
||||
query = select(TackleItem)
|
||||
if q and q.strip():
|
||||
query = query.where(TackleItem.name.ilike(f"%{q.strip()}%"))
|
||||
if category:
|
||||
query = query.where(TackleItem.category == category)
|
||||
if brand:
|
||||
|
||||
Reference in New Issue
Block a user