<commit_before>(function() {
  'use strict';
  angular.module('civic.common')
    .directive('quickSearch', quickSearch)
    .controller('quickSearchCtrl', quickSearchCtrl);

  // @ngInject
  function quickSearch() {
    var directive = {
      templateUrl: 'components/directives/quickSearch.tpl.html',
      restrict: 'E',
      scope: true,
      controller: quickSearchCtrl
    };

    return directive;
  }

  // @ngInject
  function quickSearchCtrl($scope, $state, $log, TypeAheadResults, _) {
    var topResult = {};

    $scope.getVariants = function (val) {
      return TypeAheadResults.query({ query: val, limit: 12}).$promise
        .then(function (response) {
          var labelLimit = 75;
          return _.map(response.result, function (event, index) {
            var result;
            var label = event.entrez_gene + ' / ' + event.variant;

            if (_.includes(event.terms, 'gene_aliases')) {
              var aliasLabel = event.gene_aliases.length > 1 ? 'Aliases' : 'Alias';
              label = label + ' -- ' + aliasLabel + ': ' + event.gene_aliases.join(', ');
            }

            if (_.includes(event.terms, 'drug_names')) {
              var drugLabel = event.drug_names.length > 1 ? 'Drugs' : 'Drug';
              label = label + ' -- ' + drugLabel + ': ' + event.drug_names.join(', ');
            }

            if (_.includes(event.terms, 'disease_names')) {
              var diseaseLabel = event.disease_names.length > 1 ? 'Diseases' : 'Disease';
              label = label + ' -- ' + diseaseLabel + ': ' + event.disease_names.join(', ');
            }

            if (label.length > labelLimit) { label = _.trunc(label, labelLimit); }

            result = {
              /*jshint camelcase: false */
              gene: event.entrez_name,
              geneId: event.gene_id,
              label: label,
              variant: event.variant,
              variantId: event.variant_id
            };

            if(index === 0) { topResult = result; }

            return result;
          });
        });<commit_msg>Add variant alias support to quick search<commit_after>(function() {
  'use strict';
  angular.module('civic.common')
    .directive('quickSearch', quickSearch)
    .controller('quickSearchCtrl', quickSearchCtrl);

  // @ngInject
  function quickSearch() {
    var directive = {
      templateUrl: 'components/directives/quickSearch.tpl.html',
      restrict: 'E',
      scope: true,
      controller: quickSearchCtrl
    };

    return directive;
  }

  // @ngInject
  function quickSearchCtrl($scope, $state, $log, TypeAheadResults, _) {
    var topResult = {};

    $scope.getVariants = function (val) {
      return TypeAheadResults.query({ query: val, limit: 12}).$promise
        .then(function (response) {
          var labelLimit = 75;
          return _.map(response.result, function (event, index) {
            var result;
            var label = event.entrez_gene + ' / ' + event.variant;

            if (_.includes(event.terms, 'gene_aliases')) {
              var aliasLabel = event.gene_aliases.length > 1 ? 'Aliases' : 'Alias';
              label = label + ' -- ' + aliasLabel + ': ' + event.gene_aliases.join(', ');
            }

            if (_.includes(event.terms, 'drug_names')) {
              var drugLabel = event.drug_names.length > 1 ? 'Drugs' : 'Drug';
              label = label + ' -- ' + drugLabel + ': ' + event.drug_names.join(', ');
            }

            if (_.includes(event.terms, 'disease_names')) {
              var diseaseLabel = event.disease_names.length > 1 ? 'Diseases' : 'Disease';
              label = label + ' -- ' + diseaseLabel + ': ' + event.disease_names.join(', ');
            }

            if (_.includes(event.terms, 'variant_aliases')) {
              var variantAliasLabel = event.variant_aliases.length > 1 ? 'Variant Aliases' : 'Variant Alias';
              label = label + ' -- ' + variantAliasLabel + ': ' + event.variant_aliases.join(', ');
            }

            if (label.length > labelLimit) { label = _.trunc(label, labelLimit); }

            result = {
              /*jshint camelcase: false */
              gene: event.entrez_name,
              geneId: event.gene_id,
              label: label,
              variant: event.variant,
              variantId: event.variant_id
            };

            if(index === 0) { topResult = result; }

            return result;
          });
        });
{'fraction_non_alphanumeric': 0.13943062093700964, 'fraction_numerical': 0.0038108047522976913, 'mean_word_length': 1.9201570680628273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '5616106', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1271, 'n_words': 263}