Function get_tickets

Source
pub async fn get_tickets(
    __arg0: Path<(i64, i64)>,
    __arg1: Extension<AuthUser>,
    __arg2: State<AppState>,
    __arg3: Query<FilterReq>,
) -> impl IntoResponse
Expand description

Retrieves tickets for an assignment with optional filtering, sorting, and pagination.

Endpoint: GET /modules/{module_id}/assignments/{assignment_id}/tickets
Permissions:

  • Students can only see their own tickets
  • Lecturers/assistants can see all tickets

§Path parameters

  • module_id → ID of the module (used for permission check)
  • assignment_id → ID of the assignment

§Query parameters

  • page → Page number (default: 1)
  • per_page → Number of items per page (default: 20, max: 100)
  • query → Search in ticket title or description
  • status → Filter by ticket status (open, closed)
  • sort → Comma-separated fields to sort by (prefix with - for descending)

§Responses

  • 200 OK → Tickets retrieved successfully
{
  "success": true,
  "data": {
    "tickets": [ /* Ticket objects */ ],
    "page": 1,
    "per_page": 20,
    "total": 42
  },
  "message": "Tickets retrieved successfully"
}
  • 400 Bad Request → Invalid query parameters (sort or status)
{
  "success": false,
  "data": null,
  "message": "Invalid field used"
}
  • 500 Internal Server Error → Failed to fetch tickets
{
  "success": false,
  "data": null,
  "message": "Failed to retrieve tickets"
}