<commit_before>(function() {
    var handlebarsUrl = '//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.4/handlebars.amd.min',
        requirejsUrl = '//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.14/require.min.js';

    function configureCommitStreamDependencies() {
        require.config({
            paths: {
                handlebars: handlebarsUrl
            }
        });
    }

    function queryCommitStream(commitStreamDomId, workitem, handlebars, errorHandler) {
        $.getJSON('{{{apiUrl}}}' + workitem).done(function(data) {
            if (!data || !data.commits) {
                errorHandler();
            } else {
                data.noCommits = data.commits.length < 1;
                data.resourcePath = "{{{resourcePath}}}";
                $.get('{{{templateUrl}}}').done(function(source) {
                    try {
                        var template = handlebars.compile(source);
                        var content = template(data);
                        $(commitStreamDomId).html(content);
                    } catch(ex) {
                        errorHandler();
                    }
                }).fail(errorHandler);
            }
        }).fail(errorHandler);
    }

    function invokeCommitStream(commitStreamDomId, workitem, errorHandler) {
        require(['handlebars'], function(handlebars) {
            queryCommitStream(commitStreamDomId, workitem, handlebars.default, errorHandler);
        }, errorHandler);
    }

    // Put a commitStream object in the global space
    if (!window.CommitStream) {
        window.CommitStream = {
            commitsDisplay : function(commitStreamDomId, workitem, errorHandler) {
                $.getScript(requirejsUrl, function(data, status, jqxhr) {
                    configureCommitStreamDependencies();
                    invokeCommitStream(commitStreamDomId, workitem, errorHandler);
                }).fail(errorHandler);
            }
        };
    } else {
        window.CommitStream.commitsDisplay = invokeCommitStream;
    }
})();<commit_msg>S-48712 Reduce network traffice to single req<commit_after>(function() {
    var handlebarsUrl = '//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.4/handlebars.amd.min',
        requirejsUrl = '//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.14/require.min.js';

    function configureCommitStreamDependencies() {
        require.config({
            paths: {
                handlebars: handlebarsUrl
            }
        });
    }

    var deps = ['handlebars'];
    function hasAllDeps() {
        if (!window.requirejs) return false;
        for(var i = 0; i < deps.length; i++) {
            if (!requirejs.defined(deps[i])) return false;
        }
        return true;
    }

    var assetDetailCommitsTmpl = null;
    function render(commitStreamDomId, data, errorHandler) {
        try {
            var content = assetDetailCommitsTmpl(data);
            $(commitStreamDomId).html(content);
        } catch(ex) {
            errorHandler();
        }
    }

    function queryCommitStream(commitStreamDomId, workitem, handlebars, errorHandler) {
        $.getJSON('{{{apiUrl}}}' + workitem).done(function(data) {
            if (!data || !data.commits) {
                errorHandler();
            } else {
                data.noCommits = data.commits.length < 1;
                data.resourcePath = "{{{resourcePath}}}";

                if (assetDetailCommitsTmpl === null) {
                    $.get('{{{templateUrl}}}').done(function(source) {
                        try {
                            assetDetailCommitsTmpl = handlebars.compile(source);
                            render(commitStreamDomId, data, errorHandler);
                        } catch(ex) {
                            errorHandler();
                        }
                    }).fail(errorHandler);
                } else {
                    render(commitStreamDomId, data, errorHandler);
                }
            }
        }).fail(errorHandler);
    }

    function invokeCommitStream(commitStreamDomId, workitem, errorHandler) {
        require(deps, function(handlebars) {
            queryCommitStream(commitStreamDomId, workitem, handlebars.default, errorHandler);
        }, errorHandler);
    }

    // Put a commitStream object in the global space
    if (!window.CommitStream) {
        window.CommitStream = {
            commitsDisplay : function(commitStreamDomId, workitem, errorHandler) {
                try {
                    if (!hasAllDeps()) {
                        $.getScript(requirejsUrl, function(data, status, jqxhr) {
                            configureCommitStreamDependencies();
                            invokeCommitStream(commitStreamDomId, workitem, errorHandler);
                        }).fail(errorHandler);
                    } else {
                        invokeCommitStream(commitStreamDomId, workitem, errorHandler);
                    }
                } catch (ex) {
                    console.log(ex);
                }
            }
        };
    }
})();
{'fraction_non_alphanumeric': 0.1148635381896721, 'fraction_numerical': 0.004712350284704497, 'mean_word_length': 1.6670157068062827, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5602556', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1297, 'n_words': 213}