<commit_before>(function() {
  'use strict';
  angular.module('civic.services')
    .service('TitleService', TitleService);

  // @ngInject
  // Titles are constructed by parsing the state's data.titleExp string within a scope constructed
  // of the relevant CIViC entities (gene, variant, evidenceItem, variantGroup)
  function TitleService($rootScope, Genes, Variants, Evidence, VariantGroups, _, $q, $parse) {
    $rootScope.$on('$stateChangeSuccess',function(event, toState, toParams) {
      var title = '';

      var titleScope = {
        gene: {},
        variant: {},
        evidenceItem: {},
        variantGroup: {}
      };

      // construct promises for relevant entities
      if(_.has(toParams, 'geneId') && titleScope.gene.entrez_id !== toParams.geneId) {
        var genePromise = Genes.get(toParams.geneId).$promise;
      }

      if((_.has(toParams, 'geneId') && _.has(toParams, 'variantId')) && titleScope.variant.id !== toParams.variantId) {
        var variantPromise = Variants.get({'geneId': toParams.geneId, 'variantId': toParams.variantId }).$promise;
      }

      if((_.has(toParams, 'variantGroupId')) && titleScope.variantGroup.id !== toParams.variantGroupId) {
        var variantGroupsPromise = VariantGroups.get({'variantGroupId': toParams.variantGroupId }).$promise;
      }

      if((_.has(toParams, 'geneId') && _.has(toParams, 'variantId') && _.has(toParams, 'evidenceItemId')) && titleScope.evidenceItem.id !== toParams.evidenceItemId) {
        var evidenceItemPromise = Evidence.get({'geneId': toParams.geneId, 'variantId': toParams.variantId, 'evidenceItemId': toParams.evidenceItemId }).$promise;
      }

      // resolve promises, apply $parse with constructed title scope
      $q.all({ gene: genePromise, variant: variantPromise, evidenceItem: evidenceItemPromise, variantGroup: variantGroupsPromise }).then(function(resolutions) {
        titleScope.gene = resolutions.gene;
        titleScope.variant = resolutions.variant;
        titleScope.evidenceItem = resolutions.evidenceItem;
        titleScope.variantGroup = resolutions.variantGroup;<commit_msg>TitleService now queries Variants.get() properly<commit_after>(function() {
  'use strict';
  angular.module('civic.services')
    .service('TitleService', TitleService);

  // @ngInject
  // Titles are constructed by parsing the state's data.titleExp string within a scope constructed
  // of the relevant CIViC entities (gene, variant, evidenceItem, variantGroup)
  function TitleService($rootScope, Genes, Variants, Evidence, VariantGroups, _, $q, $parse) {
    $rootScope.$on('$stateChangeSuccess',function(event, toState, toParams) {
      var title = '';

      var titleScope = {
        gene: {},
        variant: {},
        evidenceItem: {},
        variantGroup: {}
      };

      // construct promises for relevant entities
      if(_.has(toParams, 'geneId') && titleScope.gene.entrez_id !== toParams.geneId) {
        var genePromise = Genes.get(toParams.geneId).$promise;
      }

      if((_.has(toParams, 'geneId') && _.has(toParams, 'variantId')) && titleScope.variant.id !== toParams.variantId) {
        var variantPromise = Variants.get(toParams.variantId).$promise;
      }

      if((_.has(toParams, 'variantGroupId')) && titleScope.variantGroup.id !== toParams.variantGroupId) {
        var variantGroupsPromise = VariantGroups.get({'variantGroupId': toParams.variantGroupId }).$promise;
      }

      if((_.has(toParams, 'geneId') && _.has(toParams, 'variantId') && _.has(toParams, 'evidenceItemId')) && titleScope.evidenceItem.id !== toParams.evidenceItemId) {
        var evidenceItemPromise = Evidence.get({'geneId': toParams.geneId, 'variantId': toParams.variantId, 'evidenceItemId': toParams.evidenceItemId }).$promise;
      }

      // resolve promises, apply $parse with constructed title scope
      $q.all({ gene: genePromise, variant: variantPromise, evidenceItem: evidenceItemPromise, variantGroup: variantGroupsPromise }).then(function(resolutions) {
        titleScope.gene = resolutions.gene;
        titleScope.variant = resolutions.variant;
        titleScope.evidenceItem = resolutions.evidenceItem;
        titleScope.variantGroup = resolutions.variantGroup;
{'fraction_non_alphanumeric': 0.13597532036070242, 'fraction_numerical': 0.0, 'mean_word_length': 3.8281786941580758, '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': '354413', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1169, 'n_words': 249}