Find WorkItems that were assigned to X in the last 30 days

不问归期 提交于 2021-01-26 19:46:25

问题


I'm trying to find all WorkItems that were assigned to a person X in the last 30 days.
The big problem I have is the "in the last 30 days"-part.

I thought about using the "ever" or "asof" keywords, but couldn't find a good answer yet.. something like WHERE [Assigned To] = 'X' AND (([Assigned To] != 'X') asof '<30daysago>').
But this is still not a bulletproof solution.

Any better ideas?

Thanks & kind regards

Simon


回答1:


It appears that this is not possible using just WIQL, but you can get close.

The keyword @Today will give you today's date, then just subtract your range from it. The EVER keyword applied to [Status]='AssignedTo' and a comparison against a date 30 days in the past to [StateChangeDate] is what you'll need to accomplish this.

As close as you can get with WIQL and existing fields:
This says, from all revisions (status changes) return records where the user 'X' has ever been AssignedTo and the State has changed in the last 30 days. This will basically give you a slightly fuzzy picture of what your User has been working on in the last month.

WHERE [Microsoft.VSTS.Common.StateChangeDate] >= @today - 30  
  AND  [System.AssignedTo] EVER 'Bennett Aaron' 
    ORDER BY [System.State]

Add the missing field:
You could add a custom field called AssignedDate that is captured during the New->AssignedTo workflow transition that you create in the Work Item Definition XML. You can accomplish this using the Team Foundation Server Power Tools extension to Visual Studio. This would give you exactly what you need as well as additional reporting options going forward.

TFS API
I cannot help you with this one, but I believe you could query using the TFS API.



A couple of quick gotchas I've experienced to save you time on ASOF and EVER:

AsOf won't help you by itself with this as it does not support a range of dates. It allows you to query as if it were another date. In other words, if you forgot to capture the results of a query yesterday, you can use an AsOf query to get the results that you would have gotten had it run yesterday. What I understand is that you want to query a basic date range.

EVER might not work as you expect against dates as I believe it uses the exact value of the field (timestamp portion of the date field would be included) it tests with. Just make sure the EVER keyword is used against the status field rather than a date.



来源:https://stackoverflow.com/questions/5179044/find-workitems-that-were-assigned-to-x-in-the-last-30-days

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!