Get the exact status of the task when the sprint is closed

Hi,

We are trying to calculate planned efforts and actual efforts for a sprint. Right now, we are getting the project board id, then the sprints in that board and then the issues in each sprint and finally iterating all the issues to get efforts. Is there any easiest way to get all the tasks in a sprint ? and also the rest apis are giving the current status of the task but not the exact status when we close the sprint. Is there anyway to get the exact status of a task when the sprint is closed ?
Second issue is regarding velocity chart. Why doesn’t it include the story points of the tasks that are added in the middle of the sprint to committed but includes them in the completed if the status of the added task is done.

Thanks in advance.

1 Like

Hi @it1

Just using a simple /rest/api/3/search?jql=project=XXX AND sprint="Sprint 123" will give you all the items in a sprint. Adding &expand=changelog to the API call will give you the history for each item. You then need to iterate through each item.changelog.histories and for each of those iterate through histories.items - you can check the date of each change so you can work out what the last state change was before the end of the sprint.

As to the velocity chart, your sprint commitment is only at the start of the sprint, so committed will be those items at the beginning of the sprint - what you’ve described is the correct behaviour in my opinion.

Hi @warren.levy,

I guess that using the below logic could decide whether the issue’s story point is compeleted (committed vs. completed stroy points in the sprint). Is that right?
closedSprints[0].startDate < statuscategorychangedate < closedSprints[0].completeDate

{
  "expand": "schema,names",
  "startAt": 0,
  "maxResults": 50,
  "total": 1,
  "issues": [
    {
      "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
      "id": "10027",
      "self": "https://hangzhouace.atlassian.net/rest/agile/1.0/issue/10027",
      "key": "IPD-9",
      "fields": {
        "statuscategorychangedate": "2022-10-25T01:10:45.556+0800",
        "parent": {
          "id": "10019",
          "key": "IPD-1",
          "self": "https://hangzhouace.atlassian.net/rest/api/2/issue/10019",
          "fields": {
            "summary": "保单管理",
            "status": {
              "self": "https://hangzhouace.atlassian.net/rest/api/2/status/10001",
              "description": "",
              "iconUrl": "https://hangzhouace.atlassian.net/",
              "name": "Done",
              "id": "10001",
              "statusCategory": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/statuscategory/3",
                "id": 3,
                "key": "done",
                "colorName": "green",
                "name": "Done"
              }
            },
            "priority": {
              "self": "https://hangzhouace.atlassian.net/rest/api/2/priority/3",
              "iconUrl": "https://hangzhouace.atlassian.net/images/icons/priorities/medium.svg",
              "name": "Medium",
              "id": "3"
            },
            "issuetype": {
              "self": "https://hangzhouace.atlassian.net/rest/api/2/issuetype/10000",
              "id": "10000",
              "description": "A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.",
              "iconUrl": "https://hangzhouace.atlassian.net/images/icons/issuetypes/epic.svg",
              "name": "Epic",
              "subtask": false,
              "hierarchyLevel": 1
            }
          }
        },
        "customfield_10070": null,
        "customfield_10071": null,
        "customfield_10072": null,
        "customfield_10073": null,
        "customfield_10074": null,
        "customfield_10075": null,
        "customfield_10076": null,
        "customfield_10110": null,
        "fixVersions": [
          {
            "self": "https://hangzhouace.atlassian.net/rest/api/2/version/10000",
            "id": "10000",
            "description": "beta版本",
            "name": "0.1",
            "archived": true,
            "released": true,
            "releaseDate": "2022-02-11"
          }
        ],
        "customfield_10077": null,
        "customfield_10111": null,
        "customfield_10078": null,
        "customfield_10112": null,
        "customfield_10079": null,
        "resolution": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/resolution/10000",
          "id": "10000",
          "description": "Work has been completed on this issue.",
          "name": "Done"
        },
        "customfield_10113": null,
        "customfield_10114": null,
        "customfield_10104": null,
        "customfield_10105": null,
        "customfield_10106": null,
        "customfield_10107": null,
        "customfield_10108": null,
        "customfield_10109": null,
        "lastViewed": "2022-10-29T14:47:31.683+0800",
        "epic": {
          "id": 10019,
          "key": "IPD-1",
          "self": "https://hangzhouace.atlassian.net/rest/agile/1.0/epic/10019",
          "name": "保单管理",
          "summary": "保单管理",
          "color": {
            "key": "color_13"
          },
          "done": false
        },
        "priority": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/priority/3",
          "iconUrl": "https://hangzhouace.atlassian.net/images/icons/priorities/medium.svg",
          "name": "Medium",
          "id": "3"
        },
        "customfield_10069": null,
        "customfield_10102": null,
        "customfield_10103": null,
        "labels": [],
        "aggregatetimeoriginalestimate": 43200,
        "timeestimate": null,
        "versions": [],
        "issuelinks": [],
        "assignee": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/user?accountId=557058%3Ad3bfc387-7668-418a-b41c-62979817f0d9",
          "accountId": "557058:d3bfc387-7668-418a-b41c-62979817f0d9",
          "avatarUrls": {
            "48x48": "https://secure.gravatar.com/avatar/aad594a3729b04dacc6c561a3fe510d6?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FBL-2.png",
            "24x24": "https://secure.gravatar.com/avatar/aad594a3729b04dacc6c561a3fe510d6?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FBL-2.png",
            "16x16": "https://secure.gravatar.com/avatar/aad594a3729b04dacc6c561a3fe510d6?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FBL-2.png",
            "32x32": "https://secure.gravatar.com/avatar/aad594a3729b04dacc6c561a3fe510d6?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FBL-2.png"
          },
          "displayName": "bin li",
          "active": false,
          "timeZone": "Asia/Shanghai",
          "accountType": "atlassian"
        },
        "status": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/status/10001",
          "description": "",
          "iconUrl": "https://hangzhouace.atlassian.net/",
          "name": "Done",
          "id": "10001",
          "statusCategory": {
            "self": "https://hangzhouace.atlassian.net/rest/api/2/statuscategory/3",
            "id": 3,
            "key": "done",
            "colorName": "green",
            "name": "Done"
          }
        },
        "components": [
          {
            "self": "https://hangzhouace.atlassian.net/rest/api/2/component/10004",
            "id": "10004",
            "name": "保单管理"
          }
        ],
        "customfield_10051": null,
        "customfield_10052": null,
        "customfield_10054": null,
        "aggregatetimeestimate": 0,
        "creator": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/user?accountId=5f5e0bb93242e8006f363bfd",
          "accountId": "5f5e0bb93242e8006f363bfd",
          "emailAddress": "yong.yang@atlassiancommunity.com",
          "avatarUrls": {
            "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/48",
            "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/24",
            "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/16",
            "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/32"
          },
          "displayName": "YY哥",
          "active": true,
          "timeZone": "Asia/Shanghai",
          "accountType": "atlassian"
        },
        "subtasks": [
          {
            "id": "10043",
            "key": "IPD-25",
            "self": "https://hangzhouace.atlassian.net/rest/api/2/issue/10043",
            "fields": {
              "summary": "【后端】转移保单权益接口开发",
              "status": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/status/10001",
                "description": "",
                "iconUrl": "https://hangzhouace.atlassian.net/",
                "name": "Done",
                "id": "10001",
                "statusCategory": {
                  "self": "https://hangzhouace.atlassian.net/rest/api/2/statuscategory/3",
                  "id": 3,
                  "key": "done",
                  "colorName": "green",
                  "name": "Done"
                }
              },
              "priority": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/priority/3",
                "iconUrl": "https://hangzhouace.atlassian.net/images/icons/priorities/medium.svg",
                "name": "Medium",
                "id": "3"
              },
              "issuetype": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/issuetype/10003",
                "id": "10003",
                "description": "A small piece of work that's part of a larger task.",
                "iconUrl": "https://hangzhouace.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium",
                "name": "Sub-task",
                "subtask": true,
                "avatarId": 10316,
                "hierarchyLevel": -1
              }
            }
          },
          {
            "id": "10044",
            "key": "IPD-26",
            "self": "https://hangzhouace.atlassian.net/rest/api/2/issue/10044",
            "fields": {
              "summary": "【测试】转移保单权益功能测试",
              "status": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/status/10001",
                "description": "",
                "iconUrl": "https://hangzhouace.atlassian.net/",
                "name": "Done",
                "id": "10001",
                "statusCategory": {
                  "self": "https://hangzhouace.atlassian.net/rest/api/2/statuscategory/3",
                  "id": 3,
                  "key": "done",
                  "colorName": "green",
                  "name": "Done"
                }
              },
              "priority": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/priority/3",
                "iconUrl": "https://hangzhouace.atlassian.net/images/icons/priorities/medium.svg",
                "name": "Medium",
                "id": "3"
              },
              "issuetype": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/issuetype/10003",
                "id": "10003",
                "description": "A small piece of work that's part of a larger task.",
                "iconUrl": "https://hangzhouace.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium",
                "name": "Sub-task",
                "subtask": true,
                "avatarId": 10316,
                "hierarchyLevel": -1
              }
            }
          }
        ],
        "customfield_10040": null,
        "customfield_10041": null,
        "customfield_10042": [],
        "reporter": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/user?accountId=5f5e0bb93242e8006f363bfd",
          "accountId": "5f5e0bb93242e8006f363bfd",
          "emailAddress": "yong.yang@atlassiancommunity.com",
          "avatarUrls": {
            "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/48",
            "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/24",
            "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/16",
            "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/32"
          },
          "displayName": "YY哥",
          "active": true,
          "timeZone": "Asia/Shanghai",
          "accountType": "atlassian"
        },
        "aggregateprogress": {
          "progress": 43200,
          "total": 43200,
          "percent": 100
        },
        "customfield_10044": null,
        "customfield_10046": null,
        "customfield_10047": null,
        "customfield_10048": null,
        "customfield_10159": null,
        "closedSprints": [
          {
            "id": 2,
            "self": "https://hangzhouace.atlassian.net/rest/agile/1.0/sprint/2",
            "state": "closed",
            "name": "保单管理系统Sprint 1",
            "startDate": "2021-10-26T15:02:10.908Z",
            "endDate": "2021-11-02T12:54:00.000Z",
            "completeDate": "2022-03-12T03:04:24.909Z",
            "originBoardId": 4,
            "goal": "跑通保管管理最小业务闭环"
          }
        ],
        "progress": {
          "progress": 0,
          "total": 0
        },
        "votes": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/issue/IPD-9/votes",
          "votes": 0,
          "hasVoted": false
        },
        "worklog": {
          "startAt": 0,
          "maxResults": 20,
          "total": 0,
          "worklogs": []
        },
        "issuetype": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/issuetype/10001",
          "id": "10001",
          "description": "Functionality or a feature expressed as a user goal.",
          "iconUrl": "https://hangzhouace.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium",
          "name": "Story",
          "subtask": false,
          "avatarId": 10315,
          "hierarchyLevel": 0
        },
        "timespent": null,
        "customfield_10150": null,
        "sprint": null,
        "customfield_10030": 1,
        "project": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/project/10003",
          "id": "10003",
          "key": "IPD",
          "name": "保险产品研发",
          "projectTypeKey": "software",
          "simplified": false,
          "avatarUrls": {
            "48x48": "https://hangzhouace.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10415",
            "24x24": "https://hangzhouace.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10415?size=small",
            "16x16": "https://hangzhouace.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10415?size=xsmall",
            "32x32": "https://hangzhouace.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10415?size=medium"
          }
        },
        "customfield_10153": 0.219141,
        "customfield_10033": null,
        "customfield_10155": 0.219141,
        "customfield_10034": null,
        "aggregatetimespent": 43200,
        "customfield_10035": null,
        "customfield_10036": null,
        "customfield_10157": 2,
        "customfield_10037": null,
        "customfield_10158": 1,
        "customfield_10148": null,
        "customfield_10027": [],
        "customfield_10149": null,
        "customfield_10028": null,
        "customfield_10029": null,
        "resolutiondate": "2022-10-25T01:10:42.569+0800",
        "workratio": -1,
        "watches": {
          "self": "https://hangzhouace.atlassian.net/rest/api/2/issue/IPD-9/watchers",
          "watchCount": 1,
          "isWatching": true
        },
        "issuerestriction": {
          "issuerestrictions": {},
          "shouldDisplay": false
        },
        "created": "2021-08-01T13:28:24.438+0800",
        "customfield_10020": [
          {
            "id": 2,
            "name": "保单管理系统Sprint 1",
            "state": "closed",
            "boardId": 4,
            "goal": "跑通保管管理最小业务闭环",
            "startDate": "2021-10-26T15:02:10.908Z",
            "endDate": "2021-11-02T12:54:00.000Z",
            "completeDate": "2022-03-12T03:04:24.909Z"
          }
        ],
        "customfield_10021": null,
        "customfield_10022": null,
        "customfield_10023": null,
        "customfield_10024": null,
        "customfield_10025": "3_*:*_4_*:*_4970600467_*|*_10013_*:*_3_*:*_2476669560_*|*_10001_*:*_4_*:*_31388333090_*|*_10014_*:*_3_*:*_138026",
        "customfield_10026": null,
        "customfield_10016": null,
        "customfield_10017": null,
        "customfield_10018": {
          "hasEpicLinkFieldDependency": false,
          "showField": false,
          "nonEditableReason": {
            "reason": "PLUGIN_LICENSE_ERROR",
            "message": "The Parent Link is only available to Jira Premium users."
          }
        },
        "customfield_10019": "0|i0004r:",
        "updated": "2022-10-25T01:11:14.930+0800",
        "timeoriginalestimate": null,
        "customfield_10130": null,
        "description": null,
        "customfield_10010": null,
        "customfield_10014": "IPD-1",
        "customfield_10015": "2022-09-02",
        "timetracking": {},
        "customfield_10005": null,
        "customfield_10006": null,
        "customfield_10127": null,
        "customfield_10128": null,
        "customfield_10007": null,
        "security": null,
        "customfield_10008": null,
        "customfield_10129": null,
        "customfield_10009": null,
        "attachment": [],
        "flagged": false,
        "summary": "作为保单受益人,我可以给保单权益转移给其他受益人邮件",
        "customfield_10080": null,
        "customfield_10081": null,
        "customfield_10082": null,
        "customfield_10083": null,
        "customfield_10085": null,
        "customfield_10120": null,
        "customfield_10121": null,
        "customfield_10000": "{pullrequest={dataType=pullrequest, state=MERGED, stateCount=2}, build={count=1, dataType=build, failedBuildCount=0, successfulBuildCount=1, unknownBuildCount=0}, json={\"cachedValue\":{\"errors\":[],\"summary\":{\"pullrequest\":{\"overall\":{\"count\":2,\"lastUpdated\":\"2021-08-01T14:22:41.686+0800\",\"stateCount\":2,\"state\":\"MERGED\",\"dataType\":\"pullrequest\",\"open\":false},\"byInstanceType\":{\"GitLab\":{\"count\":2,\"name\":\"GitLab\"}}},\"build\":{\"overall\":{\"count\":1,\"lastUpdated\":null,\"failedBuildCount\":0,\"successfulBuildCount\":1,\"unknownBuildCount\":0,\"dataType\":\"build\"},\"byInstanceType\":{\"cloud-providers\":{\"count\":1,\"name\":\"Other providers\"}}}}},\"isStale\":true}}",
        "customfield_10001": null,
        "customfield_10122": null,
        "customfield_10123": null,
        "customfield_10002": null,
        "customfield_10003": null,
        "customfield_10124": null,
        "customfield_10004": null,
        "customfield_10125": null,
        "customfield_10115": null,
        "customfield_10116": null,
        "customfield_10117": null,
        "environment": null,
        "customfield_10118": null,
        "customfield_10119": null,
        "duedate": "2022-09-11",
        "comment": {
          "comments": [
            {
              "self": "https://hangzhouace.atlassian.net/rest/api/2/issue/10027/comment/10231",
              "id": "10231",
              "author": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/user?accountId=5f5e0bb93242e8006f363bfd",
                "accountId": "5f5e0bb93242e8006f363bfd",
                "emailAddress": "yong.yang@atlassiancommunity.com",
                "avatarUrls": {
                  "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/48",
                  "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/24",
                  "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/16",
                  "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/32"
                },
                "displayName": "YY哥",
                "active": true,
                "timeZone": "Asia/Shanghai",
                "accountType": "atlassian"
              },
              "body": "nihafda",
              "updateAuthor": {
                "self": "https://hangzhouace.atlassian.net/rest/api/2/user?accountId=5f5e0bb93242e8006f363bfd",
                "accountId": "5f5e0bb93242e8006f363bfd",
                "emailAddress": "yong.yang@atlassiancommunity.com",
                "avatarUrls": {
                  "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/48",
                  "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/24",
                  "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/16",
                  "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5f5e0bb93242e8006f363bfd/933e283a-dc6b-4d67-8343-d2cdc07a5a1f/32"
                },
                "displayName": "YY哥",
                "active": true,
                "timeZone": "Asia/Shanghai",
                "accountType": "atlassian"
              },
              "created": "2022-10-25T01:09:47.671+0800",
              "updated": "2022-10-25T01:09:51.109+0800",
              "jsdPublic": true
            }
          ],
          "self": "https://hangzhouace.atlassian.net/rest/api/2/issue/10027/comment",
          "maxResults": 1,
          "total": 1,
          "startAt": 0
        }
      }
    }
  ]
}