<commit_before>'use strict';

// TODO(mkhatib): Write tests.

angular.module('webClientApp')
  .directive('recommendButton', ['ArticleRecommendation', function (ArticleRecommendation) {

    var getUserRecommendation = function(article, recommendations) {
      for (var i=0; i < recommendations.length ; i++) {
        if (article.id === recommendations[i].article.id) {
          return recommendations[i];
        }
      }
      return null;
    };

    return {
      templateUrl: '/views/directives/recommendButton.html',
      restrict: 'A',
      scope: {
        article: '='
      },
      link: function (scope, element) {
        scope.$watch('article', function (newValue) {
          if (!newValue) {
            return;
          }

          var userRecommendation = null;
          ArticleRecommendation.query({<commit_msg>Fix the bug people unable to recommend an article.<commit_after>'use strict';

// TODO(mkhatib): Write tests.

angular.module('webClientApp')
  .directive('recommendButton', ['$rootScope', 'ArticleRecommendation', function ($rootScope, ArticleRecommendation) {

    var getUserRecommendation = function(article, recommendations) {
      if ($rootScope.currentUser) {
        for (var i=0; i < recommendations.length ; i++) {
          if ($rootScope.isOwner($rootScope.currentUser, recommendations[i])) {
            return recommendations[i];
          }
        }
      }
      return null;
    };

    return {
      templateUrl: '/views/directives/recommendButton.html',
      restrict: 'A',
      scope: {
        article: '='
      },
      link: function (scope, element) {
        scope.$watch('article', function (newValue) {
          if (!newValue) {
            return;
          }

          var userRecommendation = null;
          ArticleRecommendation.query({
{'fraction_non_alphanumeric': 0.1278236914600551, 'fraction_numerical': 0.0011019283746556473, 'mean_word_length': 2.459047619047619, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6715356', 'n_tokens_mistral': 518, 'n_tokens_neox': 496, 'n_words': 107}