Task search: q param in list_tasks (number + title ilike)
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
This commit is contained in:
parent
a4ac2a6471
commit
1f57f869ba
@ -219,6 +219,7 @@ async def list_tasks(
|
||||
status: Optional[str] = Query(None),
|
||||
assignee_id: Optional[str] = Query(None),
|
||||
label: Optional[str] = Query(None),
|
||||
search: Optional[str] = Query(None, alias="q"),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
q = select(Task).options(
|
||||
@ -237,6 +238,13 @@ async def list_tasks(
|
||||
q = q.where(Task.assignee_id == uuid.UUID(assignee_id))
|
||||
if label:
|
||||
q = q.where(Task.labels.contains([label]))
|
||||
if search:
|
||||
# Search by number or title
|
||||
try:
|
||||
num = int(search.split("-")[-1] if "-" in search else search)
|
||||
q = q.where((Task.number == num) | (Task.title.ilike(f"%{search}%")))
|
||||
except ValueError:
|
||||
q = q.where(Task.title.ilike(f"%{search}%"))
|
||||
q = q.order_by(Task.position, Task.created_at)
|
||||
result = await db.execute(q)
|
||||
return [task_out(t, t.project.slug if t.project else "") for t in result.unique().scalars()]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user