Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/dispatch/case/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,33 @@ class CaseReadMinimal(CaseBase):
assignee: ParticipantReadMinimal | None = None
case_costs: list[CaseCostReadMinimal] = []

class CaseReadMinimalWithExtras(CaseBase):
"""Pydantic model for reading minimal case data."""

id: PrimaryKey
title: str
name: NameStr | None = None
description: str | None = None
resolution: str | None = None
resolution_reason: CaseResolutionReason | None = None
visibility: Visibility | None = None
status: CaseStatus | None = None # Used in table and for action disabling
reported_at: datetime | None = None
triage_at: datetime | None = None
escalated_at: datetime | None = None
closed_at: datetime | None = None
dedicated_channel: bool | None = None # Used by CaseStatus component
case_type: CaseTypeRead
case_severity: CaseSeverityRead
case_priority: CasePriorityRead
project: ProjectRead
reporter: ParticipantReadMinimal | None = None
assignee: ParticipantReadMinimal | None = None
case_costs: list[CaseCostReadMinimal] = []
participants: list[ParticipantReadMinimal] = []
tags: list[TagRead] = []
ticket: TicketRead | None = None


CaseReadMinimal.update_forward_refs()

Expand Down Expand Up @@ -424,6 +451,10 @@ class CasePagination(Pagination):

items: list[CaseReadMinimal] = []

class CasePaginationMinimalWithExtras(Pagination):
"""Pydantic model for paginated minimal case results."""

items: list[CaseReadMinimalWithExtras] = []

class CaseExpandedPagination(Pagination):
"""Pydantic model for paginated expanded case results."""
Expand Down
11 changes: 10 additions & 1 deletion src/dispatch/case/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
case_update_flow,
get_case_participants_flow,
)
from .models import Case, CaseCreate, CaseExpandedPagination, CasePagination, CaseRead, CaseUpdate
from .models import Case, CaseCreate, CaseExpandedPagination, CasePagination, CasePaginationMinimalWithExtras, CaseRead, CaseUpdate
from .service import create, delete, get, get_participants, update

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -135,6 +135,15 @@ def get_cases(
return json.loads(CasePagination(**pagination).json())


@router.get("/minimal", summary="Retrieves a list of cases with minimal data.")
def get_cases_minimal(
common: CommonParameters,
):
"""Retrieves all cases with minimal data."""
pagination = search_filter_sort_paginate(model="Case", **common)

return json.loads(CasePaginationMinimalWithExtras(**pagination).json())

@router.post("", response_model=CaseRead, summary="Creates a new case.")
def create_case(
db_session: DbSession,
Expand Down
Loading