<commit_before>angular.module('codebrag.commits')

    .controller('DiffCtrl', function ($scope, Comments, Likes, authService) {


        $scope.like = function(fileName, lineNumber) {
            var currentUserName = authService.loggedInUser.fullName;
            if($scope.currentCommit.isUserAuthorOfCommit(currentUserName) || $scope.currentCommit.userAlreadyLikedLine(currentUserName, fileName, lineNumber)) {
                return;
            }
            var newLike = {
                commitId: $scope.currentCommit.info.id,
                fileName: fileName,
                lineNumber: lineNumber
            };
            return Likes.save(newLike).$then(function (likeResponse) {
                var like = likeResponse.data;
                $scope.currentCommit.addLike(like, fileName, lineNumber);
            });
        };

        $scope.likeEntireDiff = function () {
            var currentUserName = authService.loggedInUser.fullName;
            if ($scope.currentCommit.isUserAuthorOfCommit(currentUserName) || $scope.currentCommit.userAlreadyLikedCommit(currentUserName)) {
                return;
            }
            var newLike = {
                commitId: $scope.currentCommit.info.id
            };
            return Likes.save(newLike).$then(function (likeResponse) {
                var like = likeResponse.data;
                $scope.currentCommit.addGeneralLike(like);
            });
        };

        $scope.submitInlineComment = function(content, commentData) {
            var newComment = {
                commitId: $scope.currentCommit.info.id,
                body: content,
                fileName: commentData.fileName,
                lineNumber: commentData.lineNumber
            };

            return Comments.save(newComment).$then(function (commentResponse) {
                var comment = commentResponse.data.comment;
                $scope.currentCommit.addInlineComment(comment, commentData.fileName, commentData.lineNumber);
            });
        };

        $scope.submitComment = function (content) {
            var comment = {
                commitId: $scope.currentCommit.info.id,
                body: content
            };
            return Comments.save(comment).$then(function (commentResponse) {
                var comment = commentResponse.data.comment;
                $scope.currentCommit.addComment(comment);
            });
        };

    });
<commit_msg>Minor refactoring (extract some conditions to methods)<commit_after>angular.module('codebrag.commits')

    .controller('DiffCtrl', function ($scope, Comments, Likes, authService) {


        $scope.like = function(fileName, lineNumber) {
            var currentUserName = authService.loggedInUser.fullName;
            if(_userCannotLikeThisLine(currentUserName, fileName, lineNumber)) {
                return;
            }
            var newLike = {
                commitId: $scope.currentCommit.info.id,
                fileName: fileName,
                lineNumber: lineNumber
            };
            return Likes.save(newLike).$then(function (likeResponse) {
                var like = likeResponse.data;
                $scope.currentCommit.addLike(like, fileName, lineNumber);
            });
        };

        function _userCannotLikeThisLine(currentUserName, fileName, lineNumber) {
            return $scope.currentCommit.isUserAuthorOfCommit(currentUserName) || $scope.currentCommit.userAlreadyLikedLine(currentUserName, fileName, lineNumber);
        }

        $scope.likeEntireDiff = function () {
            var currentUserName = authService.loggedInUser.fullName;
            if (_userCannotLikeThisCommit(currentUserName)) {
                return;
            }
            var newLike = {
                commitId: $scope.currentCommit.info.id
            };
            return Likes.save(newLike).$then(function (likeResponse) {
                var like = likeResponse.data;
                $scope.currentCommit.addGeneralLike(like);
            });
        };

        function _userCannotLikeThisCommit(currentUserName) {
            return $scope.currentCommit.isUserAuthorOfCommit(currentUserName) || $scope.currentCommit.userAlreadyLikedCommit(currentUserName);
        }

        $scope.submitInlineComment = function(content, commentData) {
            var newComment = {
                commitId: $scope.currentCommit.info.id,
                body: content,
                fileName: commentData.fileName,
                lineNumber: commentData.lineNumber
            };

            return Comments.save(newComment).$then(function (commentResponse) {
                var comment = commentResponse.data.comment;
                $scope.currentCommit.addInlineComment(comment, commentData.fileName, commentData.lineNumber);
            });
        };

        $scope.submitComment = function (content) {
            var comment = {
                commitId: $scope.currentCommit.info.id,
                body: content
            };
            return Comments.save(comment).$then(function (commentResponse) {
                var comment = commentResponse.data.comment;
                $scope.currentCommit.addComment(comment);
            });
        };

    });

{'fraction_non_alphanumeric': 0.09674347743286993, 'fraction_numerical': 0.0, 'mean_word_length': 1.9129229062673323, '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': '932523', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1304, 'n_words': 204}