0

I am quite new to this so I would really appreciate your help!!!!

My repository is in TFS and I am using Visual Studio 2015 and SSMS 2016 and my manager asked me to find the "lines changed" per branch for specific author.

Could you please help in how I could achieve that?

Theo
  • 21
  • 4
  • 1
    for the records: `lines_changed != productivity` if that's what he wants this information for. – Tanner Feb 14 '17 at 11:37
  • +1 to @Tanner's comment. Is your repository Git? Then [this](http://stackoverflow.com/questions/1265040/how-to-count-total-lines-changed-by-a-specific-author-in-a-git-repository) might help. You could also try something with the TFS API, which would also work for TFVC-based repos. – Christian.K Feb 14 '17 at 11:39
  • unfortunately it is not. I am sorry but I am quite new as i said and I dont know what **lines_changed** != productivity means. Could you pls explain? @Tanner – Theo Feb 14 '17 at 11:45
  • I just mean that if your manager is looking to find out how much work an employee has done simply by looking at how many lines of code they have changed, then it's unlikely to be reliable. Some of the brightest coders get very little time to actually write code and when they do it might be a few lines here and there which are extremely good lines of code. Where as some others might write thousands of lines of code that are full of bugs and could have been written in a much simpler way. – Tanner Feb 14 '17 at 11:49
  • got that but I still have to do it :( , any suggestions how to achieve that? – Theo Feb 14 '17 at 11:52
  • I'm not sure telling your manager of a (seems like a newly acquired) job that he doesn't know what he is doing is a very good idea. How bout we help him with what he needs instead of pretending he's trying to convince his friends he is the best coder cause of # lines changed, he already stated why he needed it.. – Josh Aug 16 '17 at 18:43

1 Answers1

0

There is a FactCodeChurn table in the TFS data warehouse that should contain the data you need.

You could use some SQL query statement such as below:

   SELECT TeamProjectProjectNodeName 
          ,checkedinbyname 
          ,SUM([LinesAdded]) AS 
          ,SUM([LinesModified]) AS
          ,SUM([LinesAdded]+[LinesModified]) AS 
          ,CONVERT(VARCHAR(10), MIN(DateTime),120) AS 
          ,CONVERT(VARCHAR(10),MAX(DateTime),120) AS 
      FROM [Tfs_Warehouse].[dbo].[CodeChurnView] WHERE  TeamProjectProjectNodeName='xxx' AND  ChangesetTitle NOT LIKE 'xx'  AND FilenameFileExtension IN('.css','.cs','.aspx','.sql','js','.ascx') AND (LinesDeleted <>0 OR LinesModified<>0 OR FilenameFilePath LIKE '$/XX' AND FilenameFileExtension IN('.sql')) AND NetLinesAdded>=0   GROUP BY TeamProjectProjectNodeName, checkedinbyname 
    ORDER BY DESC

Note: You must have permission to access the Tfs_Warehouse database to execute the above statement.

Take a look at more details about Code Churn tables in warehouse database. Add a related blog including two ways using the TFS API and using the TFS Warehouse Database for your reference:

PatrickLu-MSFT
  • 44,639
  • 4
  • 24
  • 52