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

Ancestors tree endpoint for a sub-item may not return the correct order of children #458

Open
pjmonks opened this issue May 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@pjmonks
Copy link
Contributor

pjmonks commented May 8, 2024

Description

Calling GET /api/tree/folders/{domain}/{id}/ancestors may return child items in a model in a non-specific order, thereby making it appear that the children could be swapped round.

As an example, look at this UI representation of a ancestor trail:

Image

In this case, ACTIVITY COUNT is a Data Element, and ACTIVITY is a Data Class. The way this should appear is that ACTIVITY should be before ACTIVITY COUNT, but they are rendered the wrong way round. This is because the JSON returned by the ancestors endpoint returns a flat, unordered list of children from the Data Model down:

{
    "id": "3cd10f35-9144-4449-9441-881a81b3353b",
    "domainType": "Folder",
    "label": "NHS Data Dictionary",
    "hasChildren": true,
    "availableActions": [
        "createFolder",
        "createModel",
        "createVersionedFolder",
        "delete",
        "moveToFolder",
        "softDelete"
    ],
    "path": "fo:NHS Data Dictionary",
    "deleted": false,
    "children": [
        {
            "id": "4dc0a847-b22e-405f-b40f-1dbcffaeff76",
            "domainType": "VersionedFolder",
            "label": "NHS Data Dictionary (November 2023)",
            "hasChildren": true,
            "availableActions": [
                "delete",
                "moveToFolder",
                "softDelete"
            ],
            "path": "fo:NHS Data Dictionary|vf:NHS Data Dictionary (November 2023)$2023.11.0",
            "deleted": false,
            "parentFolder": "3cd10f35-9144-4449-9441-881a81b3353b",
            "finalised": true,
            "documentationVersion": "1.0.0",
            "modelVersion": "2023.11.0",
            "modelVersionTag": "November 2023",
            "children": [
                {
                    "id": "e61e2fb7-035e-4b11-b6d1-21621c74fdd9",
                    "domainType": "DataModel",
                    "label": "Classes and Attributes",
                    "hasChildren": true,
                    "availableActions": [
                        "delete",
                        "moveToContainer",
                        "moveToFolder",
                        "softDelete"
                    ],
                    "path": "dm:Classes and Attributes$2023.11.0",
                    "deleted": false,
                    "finalised": true,
                    "superseded": false,
                    "documentationVersion": "1.0.0",
                    "folder": "4dc0a847-b22e-405f-b40f-1dbcffaeff76",
                    "type": "Data Standard",
                    "modelVersion": "2023.11.0",
                    "modelVersionTag": "November 2023",
                    "children": [
                        {
                            "id": "ff8f3686-5351-43c8-b49a-24b93a9304a7",
                            "domainType": "DataElement",
                            "label": "ACTIVITY COUNT",
                            "hasChildren": false,
                            "availableActions": [
                                "delete"
                            ],
                            "path": "dm:Classes and Attributes$2023.11.0|dc:ACTIVITY|de:ACTIVITY COUNT",
                            "modelId": "e61e2fb7-035e-4b11-b6d1-21621c74fdd9",
                            "parentId": "0a2216ca-1a23-47c9-bcbe-85955efe5298"
                        },
                        {
                            "id": "0a2216ca-1a23-47c9-bcbe-85955efe5298",
                            "domainType": "DataClass",
                            "label": "ACTIVITY",
                            "hasChildren": false,
                            "availableActions": [
                                "delete"
                            ],
                            "path": "dm:Classes and Attributes$2023.11.0|dc:ACTIVITY",
                            "modelId": "e61e2fb7-035e-4b11-b6d1-21621c74fdd9"
                        }
                    ]
                }
            ]
        }
    ]
}

Expected behavior

For consistency, either:

  1. Each children array should contain one item at most, so that there is only one level at each part of the ancestor trail. Or,
  2. For children of models (sub-items), they should always be ordered correctly to avoid ambiguity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant