<commit_before>'use strict';

angular.module('OpenTMIControllers')
  .controller('ResultListController', 
             ['$scope', 'Result', 'Testcase', '$stateParams', '$timeout', '$log', '$q', 'uiGridConstants', 'uiGridGroupingConstants',
    function ($scope,   Result,    Testcase,   $stateParams,   $timeout, $log,   $q,   uiGridConstants, uiGridGroupingConstants) {
  
    $log.info('init ResultListController');
    $scope.gridMode = 'plain';

    $scope.fields = function() {
       return _.reduce($scope.columns, function(s, o){ return s+' '+o.field; }, '');
    };

    $scope.data = [];
    $scope.query = {
      q: {}, 
      s: { 'cre.time': -1}
    };
    $scope.firstPage = 0;
    $scope.lastPage = 1;
    $scope.pageSize = 100;

    $scope.setMode = function(value){
      console.log('mode change: '+value);
    }
    function checkStart(term, value, row, column) {
        term = term.replace(/\\/g,"")
        var now = moment(value);
        if(term) {
            if(moment(term).isAfter(now, 'day')) return false;;
        } 
        return true;
    }

    function checkEnd(term, value, row, column) {
        term = term.replace(/\\/g,"")
        var now = moment(value);
        if(term) {
            if(moment(term).isBefore(now, 'day')) return false;;
        } 
        return true;
    }

    var linkCellTemplate = '<div class="ngCellText" ng-class="col.colIndex()">' +
                       '<a href="#/results/{{ row.entity._id }}">{{ row.entity[col.field] }}</a>' +
                       '</div>';
    var defaultCellTemplate = '<div class="ui-grid-cell-contents"><span>{{COL_FIELD}}</span></div>';
    $scope.columns = [ 
      { field: 'cre.time', width: 140, type: 'date', 
        cellFilter: 'date:"yy/MM/dd HH:mm"', displayName: 'Date',
        filters: [
          { condition: uiGridConstants.filter.LESS_THAN },
          { condition: uiGridConstants.filter.GREATER_THAN }
        ],
        filterHeaderTemplate: 
          '<div class="ui-grid-filter-container" ng-repeat="colFilter in col.filters">'+
          '<input type="text" show-weeks="true" '+
          'class="ui-grid-filter-input" ng-model="colFilter.term" date-picker /></div>' 
      }, 
      { field: 'exec.sut.buildName', width:200, displayName: 'Build'  }, 
      { field: 'job.id', width:200, displayName: 'JobId'  }, 
      { field: 'tcid', cellTemplate: linkCellTemplate, width:200, displayName: 'TC',
        customTreeAggregationFn: function( aggregation, fieldValue, numValue, row ) {
          if ( typeof aggregation.components === 'undefined' ) { 
            aggregation.summary = {
              count: 0
            };
          }<commit_msg>add link to jobUrl from job.id (#8)<commit_after>'use strict';

angular.module('OpenTMIControllers')
  .controller('ResultListController', 
             ['$scope', 'Result', 'Testcase', '$stateParams', '$timeout', '$log', '$q', 'uiGridConstants', 'uiGridGroupingConstants',
    function ($scope,   Result,    Testcase,   $stateParams,   $timeout, $log,   $q,   uiGridConstants, uiGridGroupingConstants) {
  
    $log.info('init ResultListController');
    $scope.gridMode = 'plain';

    $scope.fields = function() {
       return _.reduce($scope.columns, function(s, o){ return s+' '+o.field; }, '')+' exec.sut.buildUrl';
    };

    $scope.data = [];
    $scope.query = {
      q: {}, 
      s: { 'cre.time': -1}
    };
    $scope.firstPage = 0;
    $scope.lastPage = 1;
    $scope.pageSize = 100;

    $scope.setMode = function(value){
      console.log('mode change: '+value);
    };
    function checkStart(term, value, row, column) {
        term = term.replace(/\\/g,"")
        var now = moment(value);
        if(term) {
            if(moment(term).isAfter(now, 'day')) return false;;
        } 
        return true;
    };

    function checkEnd(term, value, row, column) {
        term = term.replace(/\\/g,"")
        var now = moment(value);
        if(term) {
            if(moment(term).isBefore(now, 'day')) return false;;
        } 
        return true;
    };

    var linkCellTemplate = '<div class="ngCellText" ng-class="col.colIndex()">' +
                       '<a href="#/results/{{ row.entity._id }}">{{ row.entity[col.field] }}</a>' +
                       '</div>';
    var linkToJob = '<div class="ngCellText" ng-class="col.colIndex()">' +
                       '<a href="{{ row.entity.exec.sut.buildUrl }}">' +
                        '{{ COL_FIELD }}'+
                       '</a>' +
                       '</div>';

    var defaultCellTemplate = '<div class="ui-grid-cell-contents"><span>{{COL_FIELD}}</span></div>';
    $scope.columns = [ 
      { field: 'cre.time', width: 140, type: 'date', 
        cellFilter: 'date:"yy/MM/dd HH:mm"', displayName: 'Date',
        filters: [
          { condition: uiGridConstants.filter.LESS_THAN },
          { condition: uiGridConstants.filter.GREATER_THAN }
        ],
        filterHeaderTemplate: 
          '<div class="ui-grid-filter-container" ng-repeat="colFilter in col.filters">'+
          '<input type="text" show-weeks="true" '+
          'class="ui-grid-filter-input" ng-model="colFilter.term" date-picker /></div>' 
      }, 
      { field: 'exec.sut.buildName', width:200, displayName: 'Build'  }, 
      { field: 'job.id', width:200, cellTemplate: linkToJob, displayName: 'JobId'  },
      { field: 'tcid', cellTemplate: linkCellTemplate, width:200, displayName: 'TC',
        customTreeAggregationFn: function( aggregation, fieldValue, numValue, row ) {
          if ( typeof aggregation.components === 'undefined' ) { 
            aggregation.summary = {
              count: 0
            };
          }
{'fraction_non_alphanumeric': 0.17622155582995236, 'fraction_numerical': 0.006879520197565709, 'mean_word_length': 2.351063829787234, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '1206429', 'n_tokens_mistral': 1813, 'n_tokens_neox': 1725, 'n_words': 344}