<commit_before>define([
  'app',
  'utils/sortArray'
], function(app, sortArray) {
  'use strict';

  return {
    parent: 'project_details',
    url: "builds/:build_id/",
    templateUrl: 'partials/build-details.html',
    controller: function($document, $scope, $state, $http, $filter, features, projectData, buildData,
                         coverageData, stream, flash, Collection, PageTitle) {
      function getCoveragePercent(lines_covered, lines_uncovered) {
        var total_lines = lines_covered + lines_uncovered;
        if (!total_lines) {
          return 0;
        }
        return parseInt(lines_covered / total_lines * 100, 10);
      }

      function getFormattedBuildMessage(message) {
        return $filter('linkify')($filter('escape')(message));
      }

      function getPageTitle(build) {
        if (build.number) {
          return 'Build #' + build.number + ' - ' + projectData.name;
        }
        return 'Build ' + build.id + ' - ' + projectData.name;
      }

      function updateBuild(data){
        if (data.id !== $scope.build.id) {
          return;
        }
        $scope.$apply(function() {
          $scope.build = data;
        });
      }

      $scope.cancelBuild = function() {
        $http.post('/api/0/builds/' + $scope.build.id + '/cancel/')
          .success(function(data){
            $state.go('build_details', {build_id: $scope.build.id});
          })
          .error(function(){
            flash('error', 'There was an error cancelling this build.');
          });
      };

      $scope.restartBuild = function() {
        $http.post('/api/0/builds/' + $scope.build.id + '/retry/')
          .success(function(data){
            $state.go('build_details', {build_id: data.id});
          })
          .error(function(){
            flash('error', 'There was an error restarting this build.');
          });
      };


      $scope.getBuildStatus = function(build) {
        if (build.status.id == 'finished') {
          return build.result.name;
        } else {
          return build.status.name;
        }
      };

      $scope.build = buildData;
      if ($scope.build.message) {
        $scope.formattedBuildMessage = getFormattedBuildMessage($scope.build.message);
      } else {
        $scope.formattedBuildMessage = null;
      }

      $scope.eventList = buildData.events;
      $scope.previousRuns = buildData.previousRuns;
      $scope.testFailures = buildData.testFailures;
      $scope.testChanges = buildData.testChanges;
      $scope.seenBy = buildData.seenBy.slice(0, 14);
      $scope.jobList = new Collection($scope, buildData.jobs);
      $scope.phaseList = [
        {
          name: "Test",
          result: $scope.build.result,
          status: $scope.build.status
        }
      ];
      // show phase list if > 1 phase
      $scope.showPhaseList = true;

      if (features.coverage) {
        $scope.hasCoverage = (buildData.stats.lines_covered + buildData.stats.lines_uncovered) > 0;
        $scope.coveragePercent = getCoveragePercent(buildData.stats.lines_covered, buildData.stats.lines_uncovered);

        var fileCoverageData = [];
        $.each(coverageData, function(filename, item) {
          item.hasCoverage = (item.linesCovered + item.linesUncovered) > 0;
          item.hasDiffCoverage = (item.diffLinesCovered + item.diffLinesUncovered) > 0;
          item.coveragePercent = getCoveragePercent(item.linesCovered, item.linesUncovered);
          item.diffCoveragePercent = getCoveragePercent(item.diffLinesCovered, item.diffLinesUncovered);
          item.filename = filename;
          fileCoverageData.push(item);
        });

        $scope.coverageData = sortArray(fileCoverageData, function(item) { return [item.filename]; });
      }

      PageTitle.set(getPageTitle($scope.build));

      stream.addScopedChannels($scope, [
        'builds:' + $scope.build.id,
        'builds:' + $scope.build.id + ':jobs'
      ]);
      stream.addScopedSubscriber($scope, 'build.update', updateBuild);
      stream.addScopedSubscriber($scope, 'job.update', function(data) {
        if (data.build.id == $scope.build.id) {
          $scope.jobList.updateItem(data);<commit_msg>Dont report file coverage details until build is finished<commit_after>define([
  'app',
  'utils/sortArray'
], function(app, sortArray) {
  'use strict';

  return {
    parent: 'project_details',
    url: "builds/:build_id/",
    templateUrl: 'partials/build-details.html',
    controller: function($document, $scope, $state, $http, $filter, features, projectData, buildData,
                         coverageData, stream, flash, Collection, PageTitle) {
      function getCoveragePercent(lines_covered, lines_uncovered) {
        var total_lines = lines_covered + lines_uncovered;
        if (!total_lines) {
          return 0;
        }
        return parseInt(lines_covered / total_lines * 100, 10);
      }

      function getFormattedBuildMessage(message) {
        return $filter('linkify')($filter('escape')(message));
      }

      function getPageTitle(build) {
        if (build.number) {
          return 'Build #' + build.number + ' - ' + projectData.name;
        }
        return 'Build ' + build.id + ' - ' + projectData.name;
      }

      function updateBuild(data){
        if (data.id !== $scope.build.id) {
          return;
        }
        $scope.$apply(function() {
          $scope.build = data;
        });
      }

      $scope.cancelBuild = function() {
        $http.post('/api/0/builds/' + $scope.build.id + '/cancel/')
          .success(function(data){
            $state.go('build_details', {build_id: $scope.build.id});
          })
          .error(function(){
            flash('error', 'There was an error cancelling this build.');
          });
      };

      $scope.restartBuild = function() {
        $http.post('/api/0/builds/' + $scope.build.id + '/retry/')
          .success(function(data){
            $state.go('build_details', {build_id: data.id});
          })
          .error(function(){
            flash('error', 'There was an error restarting this build.');
          });
      };


      $scope.getBuildStatus = function(build) {
        if (build.status.id == 'finished') {
          return build.result.name;
        } else {
          return build.status.name;
        }
      };

      $scope.build = buildData;
      if ($scope.build.message) {
        $scope.formattedBuildMessage = getFormattedBuildMessage($scope.build.message);
      } else {
        $scope.formattedBuildMessage = null;
      }

      $scope.eventList = buildData.events;
      $scope.previousRuns = buildData.previousRuns;
      $scope.testFailures = buildData.testFailures;
      $scope.testChanges = buildData.testChanges;
      $scope.seenBy = buildData.seenBy.slice(0, 14);
      $scope.jobList = new Collection($scope, buildData.jobs);
      $scope.phaseList = [
        {
          name: "Test",
          result: $scope.build.result,
          status: $scope.build.status
        }
      ];
      // show phase list if > 1 phase
      $scope.showPhaseList = true;

      if (features.coverage && build.status.id == 'finished') {
        $scope.hasCoverage = (buildData.stats.lines_covered + buildData.stats.lines_uncovered) > 0;
        $scope.coveragePercent = getCoveragePercent(buildData.stats.lines_covered, buildData.stats.lines_uncovered);

        var fileCoverageData = [];
        $.each(coverageData, function(filename, item) {
          item.hasCoverage = (item.linesCovered + item.linesUncovered) > 0;
          item.hasDiffCoverage = (item.diffLinesCovered + item.diffLinesUncovered) > 0;
          item.coveragePercent = getCoveragePercent(item.linesCovered, item.linesUncovered);
          item.diffCoveragePercent = getCoveragePercent(item.diffLinesCovered, item.diffLinesUncovered);
          item.filename = filename;
          fileCoverageData.push(item);
        });

        $scope.coverageData = sortArray(fileCoverageData, function(item) { return [item.filename]; });
      }

      PageTitle.set(getPageTitle($scope.build));

      stream.addScopedChannels($scope, [
        'builds:' + $scope.build.id,
        'builds:' + $scope.build.id + ':jobs'
      ]);
      stream.addScopedSubscriber($scope, 'build.update', updateBuild);
      stream.addScopedSubscriber($scope, 'job.update', function(data) {
        if (data.build.id == $scope.build.id) {
          $scope.jobList.updateItem(data);
{'fraction_non_alphanumeric': 0.13780040250976677, 'fraction_numerical': 0.003551556765715639, 'mean_word_length': 2.3590457256461232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7567493', 'n_tokens_mistral': 2563, 'n_tokens_neox': 2482, 'n_words': 423}