<commit_before>'use strict';

angular.module('familyThiefApp')
  .controller('ContributionCtrl', function ($scope, $http, Auth, $location, Contribution) {
    
    // inject data of currently logged-in user into this controller
    $scope.user = Auth.getCurrentUser();
    $scope.contribution = {};
    $scope.contribution.id = Auth.getContribution(); // gets the id of the contribution that is about to be loaded
    $scope.id = Auth.getContribution(); // delete when server is returning the id in getContribution data
    $scope.newCommentText;
    $scope.hasVoted = false;
    $scope.isOwner = false;

    $scope.getContributionData = function() {
      Contribution.get({id: $scope.contribution.id}, function(contribution) {
        if(contribution.contributor === $scope.user.username) {
          $scope.isOwner = true;
        }
        console.log(contribution);
        $scope.contribution = contribution;
      });
    }

    $scope.getContributionData();

    $scope.addComment = function(form) {
      if(form.$valid) {
        var comment = {
          origDate: $scope.id,
          commenter: $scope.user.username,
          comment: $scope.newCommentText
        };
        $http.post('api/contributions/comments', comment)
          .success(function(data, status) {
            $scope.contribution.comments.push(comment);
          });
      }
    };
    $scope.upvote = function() {
      if(!$scope.hasVoted) {
        $http.post("api/contributions/votes", {
          contributionId: Auth.getContribution()
        })
        .success(function(data, status) {
          $scope.contribution.votes += 1;
          $scope.user.votes += 1;
        });
      }
    };
    
  });<commit_msg>Fixed the persisting comments error<commit_after>'use strict';

angular.module('familyThiefApp')
  .controller('ContributionCtrl', function ($scope, $http, Auth, $location, Contribution) {
    
    // inject data of currently logged-in user into this controller
    $scope.user = Auth.getCurrentUser();
    $scope.contribution = {};
    $scope.contribution.id = Auth.getContribution(); // gets the id of the contribution that is about to be loaded
    $scope.id = Auth.getContribution(); // delete when server is returning the id in getContribution data
    $scope.newCommentText;
    $scope.hasVoted = false;
    $scope.isOwner = false;

    $scope.getContributionData = function() {
      Contribution.get({id: $scope.contribution.id}, function(contribution) {
        if(contribution.contributor === $scope.user.username) {
          $scope.isOwner = true;
        }
        console.log(contribution);
        $scope.contribution = contribution;
      });
    }

    $scope.getContributionData();

    $scope.addComment = function(form) {
      if(form.$valid) {
        var comment = {
          contributionId: $scope.id,
          commenter: $scope.user.username,
          text: $scope.newCommentText
        };
        $http.post('api/contributions/comments', comment)
          .success(function(data, status) {
            comment.comment = comment.text;
            $scope.contribution.comments.push(comment);
          });
      }
    };
    $scope.upvote = function() {
      if(!$scope.hasVoted) {
        $http.post("api/contributions/votes", {
          contributionId: Auth.getContribution()
        })
        .success(function(data, status) {
          $scope.contribution.votes += 1;
          $scope.user.votes += 1;
        });
      }
    };
    
  });
{'fraction_non_alphanumeric': 0.1338695777075553, 'fraction_numerical': 0.0011490950876185005, 'mean_word_length': 2.440711462450593, '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': '129263', 'n_tokens_mistral': 1042, 'n_tokens_neox': 998, 'n_words': 194}