<commit_before>(function() {
  'use strict';
  angular.module('civic.events.genes')
    .directive('geneTalkRevisionSummary', geneTalkRevisionSummary)
    .controller('GeneTalkRevisionSummaryController', GeneTalkRevisionSummaryController);

  // @ngInject
  function geneTalkRevisionSummary() {
    var directive = {
      restrict: 'E',
      replace: true,
      require: ['^^entityTalkView', '^^entityView'],
      templateUrl: 'app/views/events/genes/talk/geneTalkRevisionSummary.tpl.html',
      link: geneTalkRevisionsSummaryLink,
      controller: 'GeneTalkRevisionSummaryController'
    };
    return directive;
  }

  // @ngInject
  function geneTalkRevisionsSummaryLink(scope, element, attributes, controllers) {
    scope.geneTalkModel= controllers[0].entityTalkModel;
    scope.geneModel = controllers[1].entityModel;
  }

  // @ngInject
  function GeneTalkRevisionSummaryController($scope, $stateParams) {
    var ctrl = $scope.ctrl = {};

    var unwatch = $scope.$watchCollection('[geneTalkModel, geneModel]', function(controllers) {
      console.log('ctrl.geneTalkRevisionsModel watch triggered.');
      var geneTalkModel = controllers[0];
      var geneModel = controllers[1];

      geneTalkModel.actions.getChange($stateParams.changeId);
      geneTalkModel.actions.getChangeComments($stateParams.changeId);

      ctrl.acceptChange = function() {
        geneTalkModel.actions.acceptChange($stateParams.changeId)
          .then(function(response) {
            geneTalkModel.actions.getChanges($stateParams.geneId); // will eventually refresh revisions data grid
            geneModel.actions.refresh(); // will eventually refresh parent gene
          });
      };

      ctrl.rejectChange = function() {
        geneTalkModel.actions.rejectChange($stateParams.changeId)
          .then(function(response) {
            geneTalkModel.actions.getChanges($stateParams.geneId);
          });
      };

      unwatch(); // watcher will only be executed once
    }, true); // use object equality
  }
})();<commit_msg>optimized gene talk summary watcher<commit_after>(function() {
  'use strict';
  angular.module('civic.events.genes')
    .directive('geneTalkRevisionSummary', geneTalkRevisionSummary)
    .controller('GeneTalkRevisionSummaryController', GeneTalkRevisionSummaryController);

  // @ngInject
  function geneTalkRevisionSummary() {
    var directive = {
      restrict: 'E',
      replace: true,
      require: ['^^entityTalkView', '^^entityView'],
      templateUrl: 'app/views/events/genes/talk/geneTalkRevisionSummary.tpl.html',
      link: geneTalkRevisionsSummaryLink,
      controller: 'GeneTalkRevisionSummaryController'
    };
    return directive;
  }

  // @ngInject
  function geneTalkRevisionsSummaryLink(scope, element, attributes, controllers) {
    scope.geneTalkModel= controllers[0].entityTalkModel;
    scope.geneModel = controllers[1].entityModel;
  }

  // @ngInject
  function GeneTalkRevisionSummaryController($scope, $stateParams) {
    var ctrl = $scope.ctrl = {};
    // wait until models linked
    var unwatch = $scope.$watchCollection('[geneTalkModel.actions, geneModel.actions]', function(controllers) {
      var geneTalkModel = controllers[0];
      var geneModel = controllers[1];

      geneTalkModel.getChange($stateParams.changeId);
      geneTalkModel.getChangeComments($stateParams.changeId);

      ctrl.acceptChange = function() {
        geneTalkModel.actions.acceptChange($stateParams.changeId)
          .then(function(response) {
            geneTalkModel.getChanges($stateParams.geneId); // will eventually refresh revisions data grid
            geneModel.refresh(); // will eventually refresh parent gene
          });
      };

      ctrl.rejectChange = function() {
        geneTalkModel.rejectChange($stateParams.changeId)
          .then(function(response) {
            geneTalkModel.getChanges($stateParams.geneId);
          });
      };
      unwatch(); // watcher will only be executed once
    });
  }
})();
{'fraction_non_alphanumeric': 0.11736736736736737, 'fraction_numerical': 0.002002002002002002, 'mean_word_length': 3.5163841807909604, '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': '5393531', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1056, 'n_words': 189}