<commit_before>'use strict';

angular.module('bcdssApp').controller('ModelsController', function($rootScope, $scope, $state, Account, Auth,
														$q, $filter, DTOptionsBuilder, DTColumnBuilder, $compile, 	
														$stateParams, ModelService, $timeout, spinnerService) {

	$scope.results = [];
	$scope.serverErrorMsg = "Something went wrong! Please contact the site administrator."
	$scope.userName = Auth.getCurrentUser();
	$scope.modelRatingResultsStatus = [];
	$scope.resultDetailsData = [];
	$scope.dtInstance = {};
	$scope.displayModelPatternTable = false;
	$scope.onlyNumbers = /^\d+$/;
	$scope.displayInsertStatus = false;
	$scope.modal = {
      instance: null
    };

	$scope.dtOptions = DTOptionsBuilder.fromFnPromise(function() {
   	 return new Promise( function(resolve, reject){
            if ($scope.results)
              resolve($scope.results);
            else
              resolve([]);
          });
   })
   .withOption('filter', false)
   .withOption('paging', false)
   .withOption('createdRow', function(row, data, dataIndex) {
           // Recompiling so we can bind Angular directive to the DT
       $compile(angular.element(row).contents())($scope);
   })

    $scope.dtColumns = [
		DTColumnBuilder.newColumn('patternIndex.modelType').withTitle('Model Type').notSortable().renderWith(function(data, type, full) {
	        return "<div>"+data+"</div>"
	    }),
	    DTColumnBuilder.newColumn('patternIndex.patternId').withTitle('Pattern Id').notSortable(),
	    DTColumnBuilder.newColumn('patternIndex.accuracy').withTitle('Pattern Accuracy').notSortable().renderWith(function(data, type, full) {
	        return "<div>"+data+"%</div>"
	    }),
	    DTColumnBuilder.newColumn('createdDate').withTitle('Created Date').notSortable().renderWith(function(data, type, full) {
	        return "<div>"+$scope.formatDate(data)+"</div>"
	    }),
	    DTColumnBuilder.newColumn('createdBy').withTitle('Created/Updated By').notSortable(),
	    DTColumnBuilder.newColumn('patternIndex.cdd').withTitle('CDD').notSortable()
    ];

    $scope.formatDate = function(date) {
        var date = new Date(date);
        return date.getFullYear() + '-' +  
            ('0' + (date.getMonth()+1)).slice(-2) + '-' + 
            ('0' + date.getDate()).slice(-2);
    };

     $scope.checkValidationErrors = function(){
    	$scope.errMessageModal = '';
        $scope.frmEditCDD.$invalid = false;

        if($scope.Cdd > 100){
        	$scope.errMessageModal = 'Cdd value must be less than 100.';
          	$scope.frmEditCDD.$invalid = true;
          	return false;
        }

        if(!($scope.Cdd % 10) == 0 || $scope.Cdd == null || $scope.Cdd.length == 0){
        	$scope.errMessageModal = 'Cdd value must be in the multiple of 10.';
          	$scope.frmEditCDD.$invalid = true;
          	return false;
        }

        return true;
    };

    $scope.clear = function() {
    	$scope.errMessageModal = null;
        $scope.Cdd = null;
    };

    $scope.isValidPatternId = function(){
    	$scope.frmPatternSearch.$invalid = false;
    	if($scope.patternId == undefined || $scope.patternId == null || $scope.patternId.length === 0 || $scope.patternId == ''){
    		$scope.frmPatternSearch.$invalid = true;
    	}

    	if($scope.patternId == undefined || $scope.patternId == null || $scope.patternId.length > 9999999999){
    		$scope.frmPatternSearch.$invalid = true;
    	}
    };

    $scope.createCddValue = function(){
    	$('#modelDialogCreateCdd').modal('show');<commit_msg>updated error message.<commit_after>'use strict';

angular.module('bcdssApp').controller('ModelsController', function($rootScope, $scope, $state, Account, Auth,
														$q, $filter, DTOptionsBuilder, DTColumnBuilder, $compile, 	
														$stateParams, ModelService, $timeout, spinnerService) {

	$scope.results = [];
	$scope.serverErrorMsg = "Something went wrong! Please contact the site administrator."
	$scope.userName = Auth.getCurrentUser();
	$scope.modelRatingResultsStatus = [];
	$scope.resultDetailsData = [];
	$scope.dtInstance = {};
	$scope.displayModelPatternTable = false;
	$scope.onlyNumbers = /^\d+$/;
	$scope.displayInsertStatus = false;
	$scope.modal = {
      instance: null
    };

	$scope.dtOptions = DTOptionsBuilder.fromFnPromise(function() {
   	 return new Promise( function(resolve, reject){
            if ($scope.results)
              resolve($scope.results);
            else
              resolve([]);
          });
   })
   .withOption('filter', false)
   .withOption('paging', false)
   .withOption('createdRow', function(row, data, dataIndex) {
           // Recompiling so we can bind Angular directive to the DT
       $compile(angular.element(row).contents())($scope);
   })

    $scope.dtColumns = [
		DTColumnBuilder.newColumn('patternIndex.modelType').withTitle('Model Type').notSortable().renderWith(function(data, type, full) {
	        return "<div>"+data+"</div>"
	    }),
	    DTColumnBuilder.newColumn('patternIndex.patternId').withTitle('Pattern Id').notSortable(),
	    DTColumnBuilder.newColumn('patternIndex.accuracy').withTitle('Pattern Accuracy').notSortable().renderWith(function(data, type, full) {
	        return "<div>"+data+"%</div>"
	    }),
	    DTColumnBuilder.newColumn('createdDate').withTitle('Created Date').notSortable().renderWith(function(data, type, full) {
	        return "<div>"+$scope.formatDate(data)+"</div>"
	    }),
	    DTColumnBuilder.newColumn('createdBy').withTitle('Created/Updated By').notSortable(),
	    DTColumnBuilder.newColumn('patternIndex.cdd').withTitle('CDD').notSortable()
    ];

    $scope.formatDate = function(date) {
        var date = new Date(date);
        return date.getFullYear() + '-' +  
            ('0' + (date.getMonth()+1)).slice(-2) + '-' + 
            ('0' + date.getDate()).slice(-2);
    };

     $scope.checkValidationErrors = function(){
    	$scope.errMessageModal = '';
        $scope.frmEditCDD.$invalid = false;

        if($scope.Cdd > 100){
        	$scope.errMessageModal = 'CDD value must be less than 100.';
          	$scope.frmEditCDD.$invalid = true;
          	return false;
        }

        if(!($scope.Cdd % 10) == 0 || $scope.Cdd == null || $scope.Cdd.length == 0){
        	$scope.errMessageModal = 'CDD value must be in the multiple of 10.';
          	$scope.frmEditCDD.$invalid = true;
          	return false;
        }

        return true;
    };

    $scope.clear = function() {
    	$scope.errMessageModal = null;
        $scope.Cdd = null;
    };

    $scope.isValidPatternId = function(){
    	$scope.frmPatternSearch.$invalid = false;
    	if($scope.patternId == undefined || $scope.patternId == null || $scope.patternId.length === 0 || $scope.patternId == ''){
    		$scope.frmPatternSearch.$invalid = true;
    	}

    	if($scope.patternId == undefined || $scope.patternId == null || $scope.patternId.length > 9999999999){
    		$scope.frmPatternSearch.$invalid = true;
    	}
    };

    $scope.createCddValue = function(){
    	$('#modelDialogCreateCdd').modal('show');
{'fraction_non_alphanumeric': 0.16385302879841113, 'fraction_numerical': 0.007944389275074478, 'mean_word_length': 3.0610599078341014, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '17102', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2110, 'n_words': 361}