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

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

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.

Related

Sort TFS Query By Itaration Start Date

I have TFS/AzureDevOps query which is sorted by Iteration Path .
I need to sort it by Iteration Start Date.
I dont see any option on the Sorting Page or in the query page to sort like this.
I tried sorting by iteration ID but the iteration were not created in order .
WIQL Code
SELECT
[System.IterationPath],
[Prod.Versions],
[System.Id],
[Prod.Territory],
[Prod.Customer],
[System.Title],
[System.AssignedTo],
[System.State]
FROM workitems
WHERE
[System.TeamProject] = #project
AND [System.WorkItemType] = 'Feature'
AND [Prod.Versions] >= '9.0'
AND [System.IterationPath] <> 'Machine'
AND [System.AreaPath] UNDER 'Machine\Development'
ORDER BY [System.IterationId],
[System.Id]
i would like it to be ordered like the following (this is from the setting page of the project in AzureDevops Server 2019 ):
We have adopted a naming convention for our iterations that uses the start date of the iteration as the name in order to achieve this.
So the iterations are named like:
2019.08.12
2019.08.26
not ideal, and I would love to see a option to include the iteration's start date a column for this very reason. Hopefully we will see a better answer soon.
Sorry, TFS work item query not support to filter Iteration using Start/End Dates.
There is a similar question here: TFS show iteration Start and End Date on PBI
Since using a name contain iteration date is not a solution for you. As another workaround, you could try get Iterations in specific Start/End dates using TFS API. Some thing maybe helpful for your reference.
Besides, in each collection database there is a table called "tbl_nodes" that holds the start-date and the end-date.
Writing a warehouse adapter that actually picks up these dates and saves them to the warehouse. Note do not write or change anything directly in database which may lose official support.
For query work item using Iteration Start/End Dates scenario, please submit it to User Voice site at: https://developercommunity.visualstudio.com/spaces/21/visual-studio-team-services.html?type=idea Microsoft engineers will evaluate any feature request seriously.

TFS query for items completed yesterday to use weekdays

I have a query for "items completed yesterday" which is super useful in standups.
But #today - 1 seems to look at calendar days, not weekdays/workdays meaning that my query isn't useable on Mondays. Is there a way to tweak it to work?
Unfortunately we cannot achieve that.
You can Set working days for team's sprint planning and tracking when calculating capacity and sprint burndown, however it's not apply to work item queries.
So, as a workaround you can create another query with Closed Date = #today - 3 specified if you are using the normal working days...(Means the "Yesterday" is Friday)
More information please see Query by date or current iteration.

Best practices for events and date ranges

I’m trying to find the best practice for how to store and then query a event like this. User has purchased 3 items on separate dates.
Over that period there were two events that were held (events added in well after the user purchased the items as a retrospect, so at the time of purchase, event was not known). I’m trying to see how many items were purchased during each event by that user. How should I do that?
One solution but it sounds weird to me: When inserting a event, scan and add a relationship to all vertices that match
Manage date-time types isn't exactly an easy task on Neo4j, even in 3.2 version.
You have two options:
Hard way: convert all date to unix "timestamp" format ('s' or 'ms' from 1970), in order to calc date ranges.
Easy, convenient way: use "APOC" (here), a set of procedures and functions available as plugin for Neo4j; installation can be a bit tricky but it's worth it, indeed. It has a good number of 'date-time' functions.

jira updated field doesn't limit respond

I'm currently interested in automation of some of our processes, so I need to query JIRA with REST. What I want to have in response is timespent of all users for a certain date. So I use the following queries:
search?jql=project=%my_project%22&updated>startOfDay(-1d)&updated<endOfDay(-1d)&fields=worklog
search?jql=project=%my_project%22&updated>%222014-08-19%22
but in response I get a lot of worklogs which was updated not only the date I pass as argument but a month before or a day after.
So I have several questions:
Am I understand right that if I track time for some issue then the updated field will be changed?
It is likely that my queries return issues which was updated for a given date in the first place. I mean if issue was updated - return it, but issue itself contains a lot of worklogs for some period of time (month I guess).
If it is true then can I limit worklogs for the issues for only given dates?
Thanks!
Yes, you are right, you can limit your query in a way like this. But I guess your syntax is invalid.
First, in both of your query, after the project part of the JQL, there's a single percentage sign, which cannot be interpreted as a char. I'm sure you wanted to write %22 there. (However, you can completely omit %22 char)
Second, the JQL part of your query string must be formed with the official JQL syntax in mind. That means when you use logical operators, like AND, then you must write that in the middle of the query. And also don't replace > with >. So, instead of
project=my_project&updated>%222014-08-19%22
the query must look like
project=my_project AND updated>2014-08-19
Note: & sign can only split the official query string parameters of the request.

In TFS how do I pull all the items that were assigned to me between certain dates in the past?

I am trying to figure out the way to pull all the items that were on my plate between certain dates. Is this possible? Could you please help me to figure out how to write a query for that? Thanks.
The best that I know how to do is to set 'Assigned To' Was Ever #Me, then manually scan the list of work items returned (setting other fields as necessary to filter the results). In the UI, at least, there isn't a way to query on historical data.
You can do this via query window as well, below is my query that i use to see what have i been working on in the past two sprints.
This will give you any tickets you worked on regardless of who they are currently assigned to (system test / uat or whatever).
You can add more clauses and have Changed Date > xxx AND ChangedDate < xxx to find what you are looking for in any given dates.

Resources