Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add route to get image Tickets #45

Merged
merged 16 commits into from
Mar 28, 2024
28 changes: 26 additions & 2 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,34 @@ def create_ticket(ticket: TicketCreate) -> Ticket:
def get_tickets():
"""Get all tickets.

This function is used to get all tickets.
This function is used to get all tickets with status open
Valimp marked this conversation as resolved.
Show resolved Hide resolved
"""
with db:
return {"tickets": list(TicketModel.select().dicts().iterator())}
return {
"tickets": list(
TicketModel.select()
.where(TicketModel.status == TicketStatus.open)
.dicts()
)
}


@api_v1_router.get("/tickets/image-moderation")
def get_image_moderation_flags():
"""Get all tickets for image moderation.

This function is used to get all tickets for image
moderation by getting all tickets of type `image` and status open.
"""
with db:
return {
"tickets": list(
TicketModel.select()
.where(TicketModel.type == IssueType.image)
.where(TicketModel.status == TicketStatus.open)
.dicts()
)
}


@api_v1_router.get("/tickets/{ticket_id}")
Expand Down