<commit_before>var app = angular.module("github", []);

app.factory('github', ['$http', '$q', function(http, q) {
    var api_root = 'https://api.github.com';

    return {
        getUser: function(username) {
            return http.get(api_root + '/users/' + username);
        },
        getRepos: function(username) {
            var repos_p = q.defer();
            var url = api_root + '/users/' + username + '/repos';
            var repos = [];

            var fetch_page = function(pagenum) {
                http.get(url + '?per_page=100&page=' + pagenum).success(function(data) {
                    if (!data.length) {
                        repos_p.resolve(repos);
                    } else {
                        repos = repos.concat(data);
                        fetch_page(pagenum + 1);
                    }
                });
            };
            fetch_page(1);
            return repos_p.promise;
        },
        getRepo: function(repo) {
            return http.get(api_root + '/repos/' + repo);
        }
    };
}]);

app.directive('ghImg', function() {
    return {
        restrict: 'E',
        scope: {
            'src': '='
        },
        template: '<img src="{{ src }}">'
    };
});

app.filter('ago', function() {
    return function(value) {
        return moment(value).fromNow(true);
    };
});
<commit_msg>Spare a request when possible<commit_after>var app = angular.module("github", []);

app.factory('github', ['$http', '$q', function(http, q) {
    var api_root = 'https://api.github.com';
    var per_page = 100;

    return {
        getUser: function(username) {
            return http.get(api_root + '/users/' + username);
        },
        getRepos: function(username) {
            var repos_p = q.defer();
            var url = api_root + '/users/' + username + '/repos';
            var repos = [];

            var fetch_page = function(pagenum) {
                http.get(url + '?per_page=' + per_page + '&page=' + pagenum).success(function(data) {
                    repos = repos.concat(data);
                    if (data.length < per_page) {
                        repos_p.resolve(repos);
                    } else {
                        fetch_page(pagenum + 1);
                    }
                });
            };
            fetch_page(1);
            return repos_p.promise;
        },
        getRepo: function(repo) {
            return http.get(api_root + '/repos/' + repo);
        }
    };
}]);

app.directive('ghImg', function() {
    return {
        restrict: 'E',
        scope: {
            'src': '='
        },
        template: '<img src="{{ src }}">'
    };
});

app.filter('ago', function() {
    return function(value) {
        return moment(value).fromNow(true);
    };
});

{'fraction_non_alphanumeric': 0.15893563466379002, 'fraction_numerical': 0.003595828838547285, 'mean_word_length': 1.495067264573991, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3463640', 'n_tokens_mistral': 841, 'n_tokens_neox': 799, 'n_words': 152}