<commit_before>(function () {
    'use strict';

    angular.module('app.core').controller('BookDetailController', BookDetailController);

    BookDetailController.$inject = ['$scope', '$routeParams', 'BookDetailService', 'BookStatusService', 'AuthorService'];

    function BookDetailController($scope, $routeParams, BookDetailService, BookStatusService, AuthorService) {
        $scope.bookStatus = BookStatusService.query();
        $scope.authors = AuthorService.query();
        
        $scope.submitBook = function submitBook() {
            var bookDAO = new BookDetailService($scope.book);
            bookDAO.$update({id: $scope.book.id});
        };
        
        BookDetailService.get({id: $routeParams.bookId}, function (data) {
            $scope.book = data;
        });
        
        $scope.addAuthor = function () {
            $scope.author = $scope.bookData.author;
            $scope.book.authors.push($scope.author);
        };

        $scope.removeAuthor = function (author) {
            var index = $scope.book.authors.indexOf(author);
            if (index != -1) {
                $scope.book.authors.splice(index, 1);
            }
        };
    }   
}());<commit_msg>add redirect to front page on successful book update<commit_after>(function () {
    'use strict';

    angular.module('app.core').controller('BookDetailController', BookDetailController);

    BookDetailController.$inject = ['$scope', '$routeParams', '$location', 'BookDetailService', 'BookStatusService', 'AuthorService'];

    function BookDetailController($scope, $routeParams, $location, BookDetailService, BookStatusService, AuthorService) {
        $scope.bookStatus = BookStatusService.query();
        $scope.authors = AuthorService.query();

        $scope.submitBook = function submitBook() {
            var bookDAO = new BookDetailService($scope.book);
            bookDAO.$update({id: $scope.book.id});
            $location.path('/library/public/ui/#/books');
        };

        BookDetailService.get({id: $routeParams.bookId}, function (data) {
            $scope.book = data;
        });

        $scope.addAuthor = function () {
            $scope.author = $scope.bookData.author;
            $scope.book.authors.push($scope.author);
        };

        $scope.removeAuthor = function (author) {
            var index = $scope.book.authors.indexOf(author);
            if (index !== -1) {
                $scope.book.authors.splice(index, 1);
            }
        };
    }
}());
{'fraction_non_alphanumeric': 0.14554178328668532, 'fraction_numerical': 0.001599360255897641, 'mean_word_length': 2.4993006993006994, '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': '7395271', 'n_tokens_mistral': 685, 'n_tokens_neox': 661, 'n_words': 115}