get_tickets

Function get_tickets 

Source
pub async fn get_tickets(
    __arg0: State<Arc<AppState>>,
) -> Result<impl IntoResponse, (StatusCode, Json<Value>)>
Expand description

Retrieves all non-archived tickets.

Returns a list of all active TicketResponse objects with user information denormalized for easier rendering. Tickets are ordered by creation date (newest first). Joins with User table to include creator information.

§Arguments

  • State(data): Application state containing AppState for database access

§Filtering

  • Excludes tickets with status “Archived”
  • Uses LEFT JOIN to include creator information from User

§Returns

  • 200 OK with array of TicketResponse objects
  • 500 Internal Server Error if database query fails

§Example Response

[
  {
    "id": 1,
    "category": "maintenance",
    "betreff": "Broken light",
    "description": "Ceiling light not working",
    "room": 101,
    "status": "open",
    "date": "2024-01-15T10:30:00Z",
    "user_id": 5,
    "user_first_name": "John",
    "user_last_name": "Doe"
  }
]