<commit_before><!DOCTYPE html>
<html>
    <head>
        <script src="sdk/scripts/VSS.SDK.min.js"></script>

        <script type="text/javascript">
            VSS.init({
                explicitNotifyLoaded: true,
                usePlatformStyles: true
            });

            VSS.require(["TFS/Dashboards/WidgetHelpers", "TFS/WorkItemTracking/RestClient"], function (WidgetHelpers, TFS_Wit_WebApi) {
                WidgetHelpers.IncludeWidgetStyles();
                VSS.register("VelocityWidget", function () {

                  var projectId = VSS.getWebContext().project.id;

                  var query = {
                          query: "SELECT [System.AssignedTo] FROM WorkItem WHERE [System.TeamProject] = '" + VSS.getWebContext().project.name + "' AND [System.State] IN ('Closed', 'Done')"
                      };

                  var getQueryInfo = function (widgetSettings) {

                          return TFS_Wit_WebApi.getClient().queryByWiql(query, projectId)
                              .then(function(result) {

                                var openWorkItems = result.workItems.map(function (wi) { return wi.id });

                                return TFS_Wit_WebApi.getClient().getWorkItems(openWorkItems)
                                  .then(function(workItems) {

                                      var iterationMap = {};
                                      var points = 0;
                                      for (var x=0;x<workItems.length;x++) {
                                          iterationMap[workItems[x].fields['System.IterationPath']] = workItems[x].fields['System.IterationPath'];
                                          var curPoints = workItems[x].fields['Microsoft.VSTS.Scheduling.StoryPoints'];
                                          if (curPoints === undefined) {
                                            curPoints = workItems[x].fields['Microsoft.VSTS.Scheduling.Effort'];
                                          }
                                          if (curPoints != undefined) {
                                            points = points + curPoints;
                                          }
                                      }
                                      var iterations = Object.keys(iterationMap).length;
                                      var velocity = (points / iterations).toFixed(1);

                                      // Create a list with query details
                                      var $list = $('<ul>');
                                      $list.append($('<li>').text("Iterations: " + iterations));
                                      $list.append($('<li>').text("Points: " + points));
                                      $list.append($('</ul>'));

                                      // Append the list to the query-info-container
                                      var $container = $('#query-info-container');
                                      $container.empty();
                                      $container.append($list);

                                      var $velocityDiv = $('#velocity');
                                      $velocityDiv.empty();
                                      $velocityDiv.append(velocity);

                                      return WidgetHelpers.WidgetStatusHelper.Success();

                                  })



                              }, function (error) {
                                  return WidgetHelpers.WidgetStatusHelper.Failure(error.message);
                              });
                  }

                  return {
                    load: function (widgetSettings) {
                        var settings = JSON.parse(widgetSettings.customSettings.data);<commit_msg>Added comments to velocity.html.<commit_after><!DOCTYPE html>
<html>
    <head>
        <script src="sdk/scripts/VSS.SDK.min.js"></script>

        <script type="text/javascript">
            VSS.init({
                explicitNotifyLoaded: true,
                usePlatformStyles: true
            });

            /* We need to use the WorkItemTracking RestClient to retrieve work item info */
            VSS.require(["TFS/Dashboards/WidgetHelpers", "TFS/WorkItemTracking/RestClient"], function (WidgetHelpers, TFS_Wit_WebApi) {
                WidgetHelpers.IncludeWidgetStyles();
                VSS.register("VelocityWidget", function () {

                  /* Retrieve the projectId for the current project */
                  var projectId = VSS.getWebContext().project.id;

                  /* Query to retrieve completed work items */
                  var query = {
                          query: "SELECT [System.AssignedTo] FROM WorkItem WHERE [System.TeamProject] = '" + VSS.getWebContext().project.name + "' AND [System.State] IN ('Closed', 'Done')"
                      };

                  var getQueryInfo = function (widgetSettings) {

                          return TFS_Wit_WebApi.getClient().queryByWiql(query, projectId)
                              .then(function(result) {

                                var openWorkItems = result.workItems.map(function (wi) { return wi.id });

                                return TFS_Wit_WebApi.getClient().getWorkItems(openWorkItems)
                                  .then(function(workItems) {

                                      /* Map of completed points by iteration */
                                      var iterationMap = {};
                                      var points = 0;

                                      /* For each completed item
                                         - create a map entry for each distinct iteration
                                         - add points to the total points
                                      */
                                      for (var x=0;x<workItems.length;x++) {
                                          iterationMap[workItems[x].fields['System.IterationPath']] = workItems[x].fields['System.IterationPath'];
                                          var curPoints = workItems[x].fields['Microsoft.VSTS.Scheduling.StoryPoints'];
                                          if (curPoints === undefined) {
                                            curPoints = workItems[x].fields['Microsoft.VSTS.Scheduling.Effort'];
                                          }
                                          if (curPoints != undefined) {
                                            points = points + curPoints;
                                          }
                                      }
                                      /* The number of iterations (that we found completed items in) */
                                      var iterations = Object.keys(iterationMap).length;

                                      /* Velocity is just the total points / number of iterations */
                                      var velocity = (points / iterations).toFixed(1);

                                      // Create a list with query details
                                      var $list = $('<ul>');
                                      $list.append($('<li>').text("Iterations: " + iterations));
                                      $list.append($('<li>').text("Points: " + points));
                                      $list.append($('</ul>'));

                                      // Append the list to the query-info-container
                                      var $container = $('#query-info-container');
                                      $container.empty();
                                      $container.append($list);

                                      var $velocityDiv = $('#velocity');
                                      $velocityDiv.empty();
                                      $velocityDiv.append(velocity);

                                      return WidgetHelpers.WidgetStatusHelper.Success();

                                  })

                              }, function (error) {
                                  return WidgetHelpers.WidgetStatusHelper.Failure(error.message);
                              });
                  }

                  return {
                    /* Apply our color setting */
                    load: function (widgetSettings) {
                        var settings = JSON.parse(widgetSettings.customSettings.data);
{'fraction_non_alphanumeric': 0.0947144377438808, 'fraction_numerical': 0.000709471443774388, 'mean_word_length': 0.9642359498374361, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 109, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2430110', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1652, 'n_words': 334}