<commit_before>angular.module('frontpress.views.home').controller('HomeDirectiveController', HomeDirectiveController);

function HomeDirectiveController($stateParams, ListPostsModel, $state, $Frontpress, BlogApi, PageHeadModel, $location, PaginationModel){
    var vc = this;
    vc.vm = ListPostsModel;
    var firstNextPageNumber = 2;
    vc.loadMorePostsAndPaginate = loadMorePostsAndPaginate;
    PageHeadModel.init();

    var params = {
        pageSize: $Frontpress.pageSize,
        pageNumber: $stateParams.pageNumber ? $stateParams.pageNumber : 1
    };

    var blogInformationPromise = BlogApi.getBlogInformation();
    var loadPostsPromise = vc.vm.loadPosts(params);   

    function _updatePosts(loadedPosts){
        var totalPagesNumber = ListPostsModel.totalPostsNumber / $Frontpress.pageSize;
        PaginationModel.setLastPageNumber(totalPagesNumber);
        _setPaginationPages(params.pageNumber); 
        vc.vm.loadExternalFeaturedImages(loadedPosts);
    }

    loadPostsPromise.then(function(loadedPosts){
        _updatePosts(loadedPosts);
    });

    _setPageMetaData();

    function loadMorePostsAndPaginate(){
        params.pageNumber++;
        var nextPageNumber = params.pageNumber ? params.pageNumber : firstNextPageNumber;
        var paginationOptions = {notify: false};
        var loadPostsPromise = vc.vm.loadPosts(params);

        loadPostsPromise.then(function(loadedPosts){
            _updatePosts(loadedPosts);
        });        

        _setPageMetaData();
        _setPaginationPages(params.pageNumber);
        $state.go('home-pagination', {pageNumber: nextPageNumber}, paginationOptions);
    }

    function _setPaginationPages(currentPageNumber){
        PaginationModel.generatePaginationFromCurrentPageNumber(currentPageNumber);
    }

    function _setPageMetaData(){
        blogInformationPromise.success(function(result){
            if(angular.isUndefined($Frontpress.overrides) || angular.isUndefined($Frontpress.overrides.title)){
                PageHeadModel.setPageTitle(result.name);
            } else {
                PageHeadModel.setPageTitle($Frontpress.overrides.title);
            }

            PageHeadModel.setPageDescription(result.description);

            var canonical = $location.absUrl().replace(/\/page\/[0-9]{1,}\/?/, '');

            PageHeadModel.setPageCanonical(canonical);
        });
    }
}
<commit_msg>[#42] Removendo funcao desnecessaria<commit_after>angular.module('frontpress.views.home').controller('HomeDirectiveController', HomeDirectiveController);

function HomeDirectiveController($stateParams, ListPostsModel, $state, $Frontpress, BlogApi, PageHeadModel, $location, PaginationModel){
    var vc = this;
    vc.vm = ListPostsModel;
    var firstNextPageNumber = 2;
    vc.loadMorePostsAndPaginate = loadMorePostsAndPaginate;
    PageHeadModel.init();

    var params = {
        pageSize: $Frontpress.pageSize,
        pageNumber: $stateParams.pageNumber ? $stateParams.pageNumber : 1
    };

    var blogInformationPromise = BlogApi.getBlogInformation();
    var loadPostsPromise = vc.vm.loadPosts(params);   

    loadPostsPromise.then(function(loadedPosts){
        var totalPagesNumber = ListPostsModel.totalPostsNumber / $Frontpress.pageSize;
        PaginationModel.setLastPageNumber(totalPagesNumber);
        _setPaginationPages(params.pageNumber); 
        vc.vm.loadExternalFeaturedImages(loadedPosts);
    });

    _setPageMetaData();

    function loadMorePostsAndPaginate(){
        params.pageNumber++;
        var nextPageNumber = params.pageNumber ? params.pageNumber : firstNextPageNumber;
        var paginationOptions = {notify: false};
        var loadPostsPromise = vc.vm.loadPosts(params);

        loadPostsPromise.then(function(loadedPosts){
            vc.vm.loadExternalFeaturedImages(loadedPosts);
        });        

        _setPageMetaData();
        _setPaginationPages(params.pageNumber);
        $state.go('home-pagination', {pageNumber: nextPageNumber}, paginationOptions);
    }

    function _setPaginationPages(currentPageNumber){
        PaginationModel.generatePaginationFromCurrentPageNumber(currentPageNumber);
    }

    function _setPageMetaData(){
        blogInformationPromise.success(function(result){
            if(angular.isUndefined($Frontpress.overrides) || angular.isUndefined($Frontpress.overrides.title)){
                PageHeadModel.setPageTitle(result.name);
            } else {
                PageHeadModel.setPageTitle($Frontpress.overrides.title);
            }

            PageHeadModel.setPageDescription(result.description);

            var canonical = $location.absUrl().replace(/\/page\/[0-9]{1,}\/?/, '');

            PageHeadModel.setPageCanonical(canonical);
        });
    }
}

{'fraction_non_alphanumeric': 0.10539575897543565, 'fraction_numerical': 0.0025194205332773464, 'mean_word_length': 3.398891966759003, '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': '5449048', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1295, 'n_words': 174}