问题
I need to create a dashboard widget for Azure DevOps that shows number of work items of a specified type, that transitioned from one state to another.
It looks like the Updates endpoint is my best bet, but that means that I would have to iterate over all of the updates of workitems for the specified type and then determine if it contains the state transition I'm looking for, e.g. Closed to Open.
https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/updates/list?view=azure-devops-server-rest-5.0
The Analytics extension looked promising, but it looks like I would need to query the Revisions dataset, and that doesn't contain the old and new values. https://docs.microsoft.com/en-us/azure/devops/report/extend-analytics/wit-analytics?view=azure-devops
The use case is to show the number of bugs that were closed then reopened in the last 90 days. I thought that I would make the work item type and from and to states configurable.
Any ideas or suggestions much appreciated!
回答1:
Best approach to get count of workitems state transitions?
At this moment, we could not query the History with State changed from one state to another state on Web UI directly.
As workaround, we could add a custom field in our custom process that gets set the value to true
when workitems state change from Closed
to New
:
Then add a Rules
to set the value of the custom field to True if the workitems state change from Closed
to New
:
Finally, we could query the workitems with following conditions:
BTW, if you want to get those workitems which state already changed from Closed to New before use above custom filed and rules, I am afraid you have to use Rest API to query the work items that in specified type:
https://docs.microsoft.com/en-us/rest/api/vsts/wit/wiql/query%20by%20wiql
Then loop the work items list to get all revisions for every work item with Revision - List API:
https://docs.microsoft.com/en-us/rest/api/vsts/wit/revisions/list
There is a article for TFS TFS SDK: Work Item History Visualizer using TFS API, you can check it for some more details.
Hope this helps.
回答2:
You may do it through PowerBI. Calculate time-in-state for an existing Analytics view
Or as you said iterate over all of the updates of workitems.
来源:https://stackoverflow.com/questions/57395738/best-approach-to-get-count-of-workitems-state-transitions