<commit_before>var API_ENDPOINT = Fanout.WebHookInboxViewer.config.apiEndpoint;
var MAX_RETRIES = 2;
var MAX_RESULTS = 3;

var WebHookInboxViewer = angular.module('WebHookInboxViewer', []);

WebHookInboxViewer.factory("Pollymer", function($q, $rootScope) {
    var count = 0;
    return {
        create: function() {
            var req = new Pollymer.Request({maxTries: MAX_RETRIES});
            var id = ++count;
            console.log("Pollymer " + id + " created");
            return {
                post: function(url) {
                    return this.start('POST', url);
                },
                get: function(url) {
                    return this.start('GET', url);
                },
                start: function(method, url) {
                    console.log("Pollymer " + id + "> start (" + method + ")");
                    var d = $q.defer();
                    req.on('error', function(reason) {
                        console.log("Pollymer " + id + "< error");
                        d.reject({code: -1, result: reason});
                        $rootScope.$apply();
                    });
                    req.on('finished', function(code, result, headers) {
                        console.log("Pollymer " + id + "< finished (" + code + ")");
                        if (code >= 200 && code < 300) {
                            d.resolve({code: code, result: result, headers: headers});
                        } else {
                            d.reject({code: code, result: result, headers: headers});
                        }
                        $rootScope.$apply();<commit_msg>Updated to poll infinitely and work with 501 error code<commit_after>var API_ENDPOINT = Fanout.WebHookInboxViewer.config.apiEndpoint;
var MAX_RESULTS = 3;

var WebHookInboxViewer = angular.module('WebHookInboxViewer', []);

WebHookInboxViewer.factory("Pollymer", function($q, $rootScope) {
    var count = 0;
    return {
        create: function() {
            // -1 maxTries indicates infinite calls.
            var req = new Pollymer.Request({maxTries: -1, errorCodes:'500,502-599'});
            var id = ++count;
            console.log("Pollymer " + id + " created");
            return {
                post: function(url) {
                    return this.start('POST', url);
                },
                get: function(url) {
                    return this.start('GET', url);
                },
                start: function(method, url) {
                    console.log("Pollymer " + id + "> start (" + method + ")");
                    var d = $q.defer();
                    req.on('error', function(reason) {
                        console.log("Pollymer " + id + "< error");
                        d.reject({code: -1, result: reason});
                        $rootScope.$apply();
                    });
                    req.on('finished', function(code, result, headers) {
                        console.log("Pollymer " + id + "< finished (" + code + ")");
                        if (code >= 200 && code < 300) {
                            d.resolve({code: code, result: result, headers: headers});
                        } else {
                            d.reject({code: code, result: result, headers: headers});
                        }
                        $rootScope.$apply();
{'fraction_non_alphanumeric': 0.13434614238903783, 'fraction_numerical': 0.009830205540661306, 'mean_word_length': 1.3598032326071678, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '2130810', 'n_tokens_mistral': 912, 'n_tokens_neox': 839, 'n_words': 191}