<commit_before>(function () {
  'use strict';

  angular
    .module('fusionSeedApp.components.typeahead')
    .directive('typeahead', typeahead);

  function typeahead(){
    'ngInject';
    return {
      restrict: 'EA',
      controller: Controller,
      link: Link,
      templateUrl: 'assets/components/typeahead/typeahead.html',
      scope: true,
      controllerAs: 'ta',
      bindToController: {
        query: '='
      },
      require: '^form'
    };
  }

  function Controller($log, $scope, $q, ConfigService, TypeaheadService){
    'ngInject';
    $log.info(ConfigService.getTypeaheadConfig());
    var ta = this;
    ta.typeaheadField = ConfigService.getTypeaheadField();
    ta.doTypeaheadSearch = doTypeaheadSearch;
    ta.selectedSomething = selectedSomething;
    ta.updateSearchQuery = updateSearchQuery;

    function selectedSomething(object){
      if(object){
        var newValue = object.originalObject[ta.typeaheadField];
        ta.query = newValue;
      }
    }

    function updateSearchQuery(inputString){
      ta.query = inputString;
    }

    function doTypeaheadSearch(userInputString, timeoutPromise) {
      var deferred = $q.defer();
      TypeaheadService.getQueryResults({
        q: userInputString
      }).then(function(resp){
        var objectToResolve = {
          data: resp.response.docs
        };
        deferred.resolve(objectToResolve);
      }).catch(function(err){<commit_msg>fix bug in typeahead code<commit_after>(function () {
  'use strict';

  angular
    .module('fusionSeedApp.components.typeahead')
    .directive('typeahead', typeahead);

  function typeahead(){
    'ngInject';
    return {
      restrict: 'EA',
      controller: Controller,
      link: Link,
      templateUrl: 'assets/components/typeahead/typeahead.html',
      scope: true,
      controllerAs: 'ta',
      bindToController: {
        query: '='
      },
      require: '^form'
    };
  }

  function Controller($log, $scope, $q, ConfigService, TypeaheadService){
    'ngInject';
    $log.info(ConfigService.getTypeaheadConfig());
    var ta = this;
    ta.typeaheadField = ConfigService.getTypeaheadField();
    ta.doTypeaheadSearch = doTypeaheadSearch;
    ta.selectedSomething = selectedSomething;
    ta.updateSearchQuery = updateSearchQuery;

    //////////

    function selectedSomething(object){
      if(object){
        var newValue = object.originalObject[ta.typeaheadField];
        ta.query = newValue;
      }
    }

    function updateSearchQuery(inputString){
      ta.query = inputString;
    }

    function doTypeaheadSearch(userInputString, timeoutPromise) {
      var deferred = $q.defer();
      TypeaheadService.getQueryResults({
        q: userInputString
      }).then(function(resp){
        var objectToResolve = {
          data: resp.response.docs
        };
        deferred.resolve(objectToResolve);
      }).catch(function(error){
{'fraction_non_alphanumeric': 0.11991729841488628, 'fraction_numerical': 0.0, 'mean_word_length': 2.8247694334650855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1214077', 'n_tokens_mistral': 861, 'n_tokens_neox': 826, 'n_words': 151}