<commit_before>function FacilitySearchController($scope, facilities, $location) {

  $scope.facilityList = facilities;

  $scope.editFacility = function (id) {
    $location.path('edit/' + id);
  };


  $scope.filterFacilitiesByNameOrCode = function(query) {
    var filteredFacilities = [];
    var queryRegExp = RegExp(query, 'i');
    angular.forEach($scope.facilityList, function(facility) {
      if (facility.name.match(queryRegExp) || facility.code.match(queryRegExp)) {
        filteredFacilities.push(facility);
      }
    });
    $scope.resultCount = filteredFacilities.length;
    return filteredFacilities;
  };

  $scope.clearSearch = function() {
    $scope.query = "";
    $scope.resultCount = 0;
    angular.element("#searchFacility").focus();
  };
}

FacilitySearchController.resolve = {
  facilities:function ($q, $timeout, AllFacilities) {
    var deferred = $q.defer();
    $timeout(function () {
      AllFacilities.get({}, function (data) {
        deferred.resolve(data.facilityList);
      }, {});
    }, 100);
    return deferred.promise;
  }
};
<commit_msg>#316 | Jaideep | Search facility: replacing regex match with exact substring match<commit_after>function FacilitySearchController($scope, facilities, $location) {

  $scope.facilityList = facilities;

  $scope.editFacility = function (id) {
    $location.path('edit/' + id);
  };


  $scope.filterFacilitiesByNameOrCode = function(query) {
    var filteredFacilities = [];
    query = query || "";

    angular.forEach($scope.facilityList, function(facility) {
      if (facility.name.toLowerCase().indexOf(query.toLowerCase()) >= 0 || facility.code.toLowerCase().indexOf(query.toLowerCase()) >= 0) {
        filteredFacilities.push(facility);
      }
    });
    $scope.resultCount = filteredFacilities.length;
    return filteredFacilities;
  };

  $scope.clearSearch = function() {
    $scope.query = "";
    $scope.resultCount = 0;
    angular.element("#searchFacility").focus();
  };
}

FacilitySearchController.resolve = {
  facilities:function ($q, $timeout, AllFacilities) {
    var deferred = $q.defer();
    $timeout(function () {
      AllFacilities.get({}, function (data) {
        deferred.resolve(data.facilityList);
      }, {});
    }, 100);
    return deferred.promise;
  }
};

{'fraction_non_alphanumeric': 0.15225976305397104, 'fraction_numerical': 0.005704256252742431, 'mean_word_length': 3.6721311475409837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7595013', 'n_tokens_mistral': 704, 'n_tokens_neox': 686, 'n_words': 112}