Mark features done if stories are completed

The following flow demonstrates how, if all stories are done for a feature that is in testing, you can set the feature to done.

Entity relationship diagram

We need to access the following entities for this flow, and understand the relationships between these entities.

Entity relationship diagram for marking features done if stories are completed.

The following shows the relations in the flow.

Entity Relationships in this flow Description of relationship Reference / relationship fields
Work items Epics, features, defects, quality stories and user stories This aggregate resource collection represents types of work items, including epics, features, defects, user stories, and quality stories. subtype
Epics Work items

Epics are subtypes of work_items.

There is no field that relates back to the aggregate resource collection, work_items.

None
Epics Features

Epics can be associated with features.

None
Features Work items

Features are subtypes of work_items.

There is no field that relates back to the aggregate resource collection, work_items.

None
Features

Epics

Features can be associated with epics.

parent
Features

Quality stories, user stories, and defects

Features can be associated with user stories, quality stories, and defects.

None
User Stories Work items

User stories are subtypes of work_items.

There is no field that relates back to the aggregate resource collection, work_items.

None
User Stories Features

User stories can be associated with features.

parent
User Stories Defects

User stories can be associated with defects.

None
User Stories Tasks User stories can be associated with tasks. story
Quality Stories Work items

Quality stories are subtypes of work_items.

There is no field that relates back to the aggregate resource collection, work_items.

None
Quality Stories Features

Quality stories can be associated with features.

parent
Quality Stories Defects

Quality stories can be associated with defects.

None
Quality Stories Tasks Quality stories can be associated with tasks. story
Defects Work items

Defects are subtypes of work_items.

There is no field that relates back to the aggregate resource collection, work_items.

None
Defects Features

Defects can be associated with features.

parent
Defects User stories and quality stories

Defects can be associated with user stories and quality stories.

None
Defects Tasks

Defects can be associated with tasks.

defect
Phases Features, all stories, and defects Features, user stories, quality stories, and defects must be associated with a phase. phase
Users All work items Epics, features, user stories, quality stories, and defects can be associated with an owner. owner

Back to top

Flow

Let's create the REST API call step-by-step.

  1. We want to see all features that are in testing.

    We use the fields clause to control which fields are returned by the API call. Not all fields are returned automatically, so here we are going to be specific.  We want to see if any of the in-progress stories are associated with tasks, so we add story_count to our list of fields.

    We enter a query clause that lists only those work items whose subtype is feature and whose phase is still intesting. We use the And operator ; to add more query clauses.

    We use the phase reference field using the id field to specify the status.

    GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/work_items?fields=phase,release,name,id,subtype,user_story_count&query="(subtype EQ ^feature^;phase EQ {id=^phase.feature.intesting^})"

    We see one feature is in testing, 1018, and it has a story count of 2.

    {
        "total_count": 1,
        "data": [
            {
                "type": "work_item",
                "workspace_id": 1002,
                "phase": {
                    "type": "phase",
                    "logical_name": "phase.feature.intesting",
                    "name": "In Testing",
                    "index": 2,
                    "id": "1025"
                },
                "logical_name": "nz9e5ppe8d9egf1o32kvl5mlq",
                "subtype": "feature",
                "release": {
                    "type": "release",
                    "name": "My Release 1",
                    "id": "1001"
                },
                "name": "My Feature 3",
                "id": "1018",
                "user_story_count": 2
            }
        ],
        "exceeds_total_count": false
    }
  2. For each feature, we will check if the corresponding stories are done.

    Here, we are checking for:

    • The stories corresponding to feature 1018, using the parent relationship: parent={id EQ ^1018^}

    • Only stories, not defects: subtype EQ ^story^

    • Stories that are not yet done, using the Not operator !!phase={id= EQ ^phase.story.done^}

    We use the operator ; to separate between multiple query clauses with And logic.

    This example also demonstrates the use of reference fields: 

    • We use the parent reference field using the id field to specify the feature.

    • We use the phase reference field using the id field to specify the phase.

    GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/work_items?fields=phase,release,name,parent,id,subtype&query="(parent EQ {id EQ ^1018^};subtype EQ ^story^;!phase EQ {id EQ ^phase.story.done^})"

    The response shows two user stories that are new, 1019 and 1020: 

    {
        "total_count": 2,
        "data": [
            {
                "type": "work_item",
                "workspace_id": 1002,
                "phase": {
                    "type": "phase",
                    "logical_name": "phase.story.new",
                    "name": "New",
                    "index": 0,
                    "id": "1027"
                },
                "parent": {
                    "type": "feature",
                    "name": "My Feature 3",
                    "id": "1018"
                },
                "logical_name": "9p06wk981gremb0zj1n17xzdr",
                "subtype": "story",
                "release": {
                    "type": "release",
                    "name": "My Release 1",
                    "id": "1001"
                },
                "name": "User Story 400",
                "id": "1019"
            },
            {
                "type": "work_item",
                "workspace_id": 1002,
                "phase": {
                    "type": "phase",
                    "logical_name": "phase.story.new",
                    "name": "New",
                    "index": 0,
                    "id": "1027"
                },
                "parent": {
                    "type": "feature",
                    "name": "My Feature 3",
                    "id": "1018"
                },
                "logical_name": "1e7jx1jegjmnmh0rolyglx2v6",
                "subtype": "story",
                "release": {
                    "type": "release",
                    "name": "My Release 1",
                    "id": "1001"
                },
                "name": "User Story 401",
                "id": "1020"
            }
        ],
        "exceeds_total_count": false
    }

    If all the corresponding user stories were done, this would be the result: 

    {
        "total_count": 0,
        "data": [],
        "exceeds_total_count": false
    }
  3. When all user stories are done, we can set the feature's phase to done also: 

    PUT .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/work_items//1018

    {
       "phase":{ 
            "type":"phase",
            "id":"phase.feature.done"
           },
    }

    Tip:

    Instead of working with the aggregate resource collection work_items, you can also work with the features resource: 

    PUT .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/features//1018/

Back to top

See also: