Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

fix: allow GET on incidents/cases to include participants & other fields#5935

Merged
aaronherman merged 3 commits into
mainfrom
fix/add-participants
Apr 28, 2025
Merged

fix: allow GET on incidents/cases to include participants & other fields#5935
aaronherman merged 3 commits into
mainfrom
fix/add-participants

Conversation

@aaronherman

Copy link
Copy Markdown
Contributor

A user reported that include[]=participants hasn't been working for a few months. We currently are using the CasePagination for get_cases but I think we should use CaseExpandedPagination to support all include[] options.

@aaronherman aaronherman added the bug Something isn't working label Apr 28, 2025
@aaronherman aaronherman requested review from a user, mvilanova and whitdog47 April 28, 2025 22:31
@aaronherman aaronherman self-assigned this Apr 28, 2025
@ghost

ghost commented Apr 28, 2025

Copy link
Copy Markdown

Does that resolve the issue? If so, would Incidents have a similar issue?

@router.get("", summary="Retrieve a list of incidents.")
def get_incidents(
    common: CommonParameters,
    include: List[str] = Query([], alias="include[]"),
    expand: bool = Query(default=False),
):
    """Retrieves a list of incidents."""
    pagination = search_filter_sort_paginate(model="Incident", **common)

    if expand:
        return json.loads(IncidentExpandedPagination(**pagination).json())

    if include:
        # only allow two levels for now
        include_sets = create_pydantic_include(include)

        include_fields = {
            "items": {"__all__": include_sets},
            "itemsPerPage": ...,
            "page": ...,
            "total": ...,
        }
        return json.loads(IncidentPagination(**pagination).json(include=include_fields))
    return json.loads(IncidentPagination(**pagination).json())

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless, I do think we want this change.

@aaronherman aaronherman changed the title fix: allow GET /cases to include participants fix: allow GET on incidents/cases to include participants & other fields Apr 28, 2025
@aaronherman

Copy link
Copy Markdown
Contributor Author

Good catch - I validated that incidents also don't support all fields and have updated it to use IncidentExpandedPagination

@aaronherman aaronherman merged commit 4a5eb49 into main Apr 28, 2025
10 checks passed
@aaronherman aaronherman deleted the fix/add-participants branch April 28, 2025 22:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant