Skip to content

Commit 44ebd22

Browse files
feat(api): add barcode filter to tickets endpoint (#153)
- Adds barcode filtering to the get_tickets endpoint fixes: #152 Part of: openfoodfacts/openfoodfacts-explorer#639
1 parent cdbe7e9 commit 44ebd22

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

app/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ class GetTicketsResponse(BaseModel):
386386

387387
@api_v1_router.get("/tickets")
388388
def get_tickets(
389+
barcode: str | None = None,
389390
status: TicketStatus | None = None,
390391
type_: IssueType | None = None,
391392
reason: Annotated[list[ReasonType] | None, Query()] = None,
@@ -401,6 +402,8 @@ def get_tickets(
401402
offset = (page - 1) * page_size
402403
# Get IDs of flags with the specified filters
403404
where_clause = []
405+
if barcode:
406+
where_clause.append(TicketModel.barcode == barcode)
404407
if status:
405408
where_clause.append(TicketModel.status == status)
406409
if type_:

0 commit comments

Comments
 (0)