Notion of a branch in TFS_Warehouse - tfs

I'm trying to enhance the following query such that it returns all change sets on a specific branch. Unfortunately, I can't seem to find the notion of a branch in the warehouse.
SELECT [ChangesetSK]
,[ChangesetTitle]
,[LastUpdatedDateTime]
,[CheckedInBy__Name]
FROM [Tfs_Warehouse].[dbo].[vDimChangesetOverlay]
Where [LastUpdatedDateTime] > '2012-11-26 00:00:00'

Related

Azure Search: Group By or Distinct in OData context / Query?

Using Azure Search service I need to be able to group by or use distinct by a field in the query.
Use case:
My business model has the concept of "resources" which have >=1 revisions. 1 revision is 1 document in an Azure index. I need to simulate something like "select the most recently changed resources from the index while also allowing pagination", therefore I need something like an ability to group the documents from the index into resources and search by them
Azure Search does not support operators like distinct or group-by directly in the query language. However, there are potentially other ways to achieve what you want.
One way would be to make each document in your index a resource instead of a revision of a resource. Then you could have a complex collection field to represent the revisions of each resource. There are a few potential caveats to this approach:
It doesn't scale well if there are many (i.e. -- thousands) of revisions per resource. In fact, there is a limit of 3000 complex objects across all collections in a document.
To add a new revision, you'd have to read-modify-write the entire collection of revisions, since Azure Search doesn't support intra-collection merges.
If the primary unit of querying is really revisions and not resources, then modeling revisions as documents is more natural. However, you can always have more than one index depending on the query patterns you need.
Another approach would be to add a Boolean field like IsLatestVersion, but then you'd need to set the flag to false on the previous revision whenever you add a new revision to your index. The approach above using complex types would probably be more straightforward.

Subrequest in WIQL

How can I use subrequest in WIQL TFS?
I need something like this
SELECT
[System.Id]
FROM workitems
WHERE [System.Id] IN (
SELECT
[System.Id]
FROM workitems
WHERE [System.Title] == 'Example'
)
Sorry, this is not available at present. There has already been a related user voice here:
TFS: Queries based on results of other queries
https://visualstudio.uservoice.com/forums/330519-azure-devops-formerly-visual-studio-team-services/suggestions/2300378-tfs-queries-based-on-results-of-other-queries
As a workaround to execute sub queries or joins using the TFS query execution engine you will have to use the method RunLinkQuery().
For a detail sample you could take a look at this blog: Using the TFS API to display results of a Hierarchical Work Item Query

Querying JIRA to Produce Counts of Issues by Different Type

Suppose I have the following JIRA filter.
project = XXX AND resolution = Unresolved AND assignee in (EMPTY) ORDER BY Type asc, priority desc
I use it to see all unassigned issues in a certain project and pull from for triage.
Every now-and-then, I need to know how many are in each Type, i.e., I actually want a count for each.
How could I modify this query to do that or write a new one that accomplishes the same thing?
Remember that JQL isn't SQL - it just operates on tickets and returns lists of them for other parts of JIRA to consume, and doesn't really have a mechanism for counting results.
That said, you can use the JIRA REST API's /search endpoint along with maxResults=0 to construct JQL queries for each Type you care about, and the endpoint will give you a total value for that ticket Type:
https://jira.url/rest/api/latest/search?jql=project%20=%20XXX%20AND%20resolution%20=%20Unresolved%20AND%20assignee%20in%20%28EMPTY%29%20AND%20Type%20=%20Task&maxResults=0
Results in this output for Type=Task:
{
"startAt":0,
"maxResults":0,
"total":123,
"issues":[]
}

Get the Area details from AreaID in TFS 2017

It seems there isn't any Database documentation for a given collection in TFS 2017 - e.g. DefaultCollection.
I can get WorkItems from dbo.vw_WorkItemCoreAll & dbo.vw_WorkItemCustomAll, but I can't seem to join on the AreaID that is given to tbl_Area.
What am I missing?
It appears the joining has changed for TFS 2017.
In general I would recommend using the TFS_Warehouse, if the database must be used at all. Areas in TFS_Warehouse are much more straightforward than the TFS_[YOURCOLLECTION] Database.
That being said, if you must use the actual raw database, then here's a query that will join the necessary info:
SELECT * FROM dbo.vw_WorkItemCoreAll w
INNER JOIN dbo.tbl_ClassificationNode c ON w.AreaId = c.Id
WHERE
id = SOMEID
ORDER BY w.Rev DESC
It appears that tbl_Area doesn't contain the actual classifications used for WorkItems anymore.
Disclaimer: This is a last resort - the MSFT preferred mechanism for obtaining this info is the TFS REST API, for the usual API reasons (flexibility, reproducibility, etc.).
In this case I wanted to run an SSRS report (didn't care if it broke in a few months), which works better on raw DBs.

TFS 2010: Real time reporting

I would like to create a report that shows the iteration status in real time. I was able to create a query on the Tfs_Warehouse database (see below) however I found that this database is populated from the Tfs_Collection database on timely basis.
Is there a way that I can see the changes to the work items reflected in the report right away?
SELECT *
FROM [CurrentWorkItemView] c
left join [vDimWorkItemTreeOverlay] t on t.WorkItemSK = c.WorkItemSK
where c.IterationName = #iteration and c.System_WorkItemType = 'User Story'
order by c.Microsoft_VSTS_Common_StackRank, c.System_id
Note: this not the full query because I couldn't fit it nicely. Basically it joins 2 table (CurrentWorkItemView and vDimWorkItemTreeOverlay) to get the user stories and associated tasks to each user story.
No, not through the warehouse. When you need up to date information from the work items, use a work item query in Excel or Visual Studio.
You can also use the TFS api to query the operational datastore directly.

Resources