<commit_before>'use strict';

angular.module('main', ['ngRoute', 'ngSanitize', 'ui.bootstrap', 'jmdobry.angular-cache', 'googlechart', 'navbar-toggle', 'scroll-id', 'document-click', 'autocomplete', 'ngenter', 'constants', 'ngProgressLite', 'stickyFooter', 'angulartics', 'angulartics.google.analytics', 'navbar-toggle'])
.run(function($rootScope, ngProgressLite) {
        
    $rootScope.$on('$routeChangeStart', function() {
        ngProgressLite.start();
    }); 
        
    $rootScope.$on('$routeChangeSuccess', function() {
        ngProgressLite.done();
    }); 
})
.factory('$backend', function($q, $http, API_URL, DEBUG) {
    return {
		API_URL: API_URL,
		DEBUG: DEBUG,

        data: [],

        getYears : function() {
            var that = this;
            var deferred = $q.defer();
            if (!that.data['year'] || that.data['year'].length == 0)
            {
                that.data["year"] = [];
                var year = (new Date()).getFullYear();
                while (year >= 2009) { that.data["year"].push(year); year -= 1; }
            }
            deferred.resolve(that.data['year']);
            return deferred.promise;
        },

		getPeriods : function() { 
			var that = this;
            var deferred = $q.defer();
            if (!that.data['period'] || that.data['period'].length == 0)
            {
                that.data["period"] = [ 'FY', 'Q3', 'Q2', 'Q1' ];
            }
            deferred.resolve(that.data['period']);
            return deferred.promise;
		},

        getDomainMembers: function(domain) {
            var that = this;
            var deferred = $q.defer();
            if (that.data[domain] && that.data[domain].length > 0)
            {
                deferred.resolve(that.data[domain]);
                return deferred.promise;
            }

            var url;
            switch (domain)
            {
                case 'sector' :
                    url = API_URL + '/_queries/public/FilerSectorList.jq';
                    break;
            
                case 'generator' :
                    url = API_URL + '/_queries/public/GeneratorList.jq';
                    break;
            
                case 'entityType' :
                    url = API_URL + '/_queries/public/EntityTypeList.jq';
                    break;
            
                case 'stockIndex' :
                    url = API_URL + '/_queries/public/StockIndexList.jq';
                    break;    
            }
            if (url) 
                $http({ method: 'GET', url: url, params: { _method: 'POST' }, cache: true })
                    .success(function(data, status, headers, config) {
                        that.data[domain] =  [];
                        if (data && data.members){
                            data.members.forEach(function(item) {
                                that.data[domain].push(item[domain]);
                            });
                        }
                        deferred.resolve(that.data[domain]);
                    });
            return deferred.promise;
        },

        getTags : function() {
            var that = this;
            var deferred = $q.defer();
            if (!that.data['tag'] || that.data['tag'].length == 0)
            {
                that.data["tag"] = [ "DOW30",
                                "SP500",
                                "FORTUNE100",
                                "PJI" ];
            }
            deferred.resolve(that.data['tag']);
            return deferred.promise;
        },

        getEntities: function() {
            var that = this;
            var deferred = $q.defer();
            if (that.data['entities'] && that.data['entities'].length > 0)
            {
                deferred.resolve(that.data['entities']);
                return deferred.promise;
            }

            $http({ method: 'GET', url: API_URL + '/_queries/public/EntityNameTickerCIKTuples.jq', params: { _method: 'POST' }, cache: true })
                .success(function(data, status, headers, config) {
                    that.data['entities'] =  [];
                    if (data) that.data['entities'] = data.entityNameTickerSymbolCikTuples;
                    deferred.resolve(that.data['entities']);
                });

            return deferred.promise;

        },

        getConceptMaps: function() {
            var that = this;
            var deferred = $q.defer();
            if (that.data['conceptMaps'] && that.data['conceptMaps'].length > 0)
            {
                deferred.resolve(that.data['conceptMaps']);
                return deferred.promise;
            }

            $http({ method: 'GET', url: API_URL + '/_queries/public/ConceptMaps.jq', params: { _method: 'POST' }, cache: true })
                .success(function(data, status, headers, config) {
                    that.data['conceptMaps'] =  [];
                    if (data) that.data['conceptMaps'] = data.availableMaps;
                    deferred.resolve(that.data['conceptMaps']);
                });

            return deferred.promise;
        }
    };
})
.config(function ($routeProvider, $locationProvider, $httpProvider) {

    $locationProvider.html5Mode(true);

    $routeProvider
        .when('/', {
            templateUrl: '/views/home.html'
        })
        .when('/clear', {
            templateUrl: '/views/home.html',
            resolve: {
                cache: ['$angularCacheFactory', function($angularCacheFactory) { $angularCacheFactory.get('secxbrl').removeAll(); }]
            }
        })
        .when('/about', {
            templateUrl: '/views/about.html',
        })
        .when('/api', {
            templateUrl: '/views/api.html',
            controller: 'ApiCtrl'
        })
        .when('/analytics', {
            templateUrl: '/views/analytics.html',
            controller: 'AnalyticsCtrl',
            resolve: {
                years: ['$backend', function($backend) { return $backend.getYears(); }],<commit_msg>Add back global snipper interceptor<commit_after>'use strict';

angular.module('main', ['ngRoute', 'ngSanitize', 'ui.bootstrap', 'jmdobry.angular-cache', 'googlechart', 'navbar-toggle', 'scroll-id', 'document-click', 'autocomplete', 'ngenter', 'constants', 'ngProgressLite', 'stickyFooter', 'angulartics', 'angulartics.google.analytics', 'navbar-toggle'])
.run(function($rootScope, ngProgressLite) {
        
    $rootScope.$on('$routeChangeStart', function() {
        ngProgressLite.start();
    }); 
        
    $rootScope.$on('$routeChangeSuccess', function() {
        ngProgressLite.done();
    }); 
})
.factory('$backend', function($q, $http, API_URL, DEBUG) {
    return {
		API_URL: API_URL,
		DEBUG: DEBUG,

        data: [],

        getYears : function() {
            var that = this;
            var deferred = $q.defer();
            if (!that.data['year'] || that.data['year'].length == 0)
            {
                that.data["year"] = [];
                var year = (new Date()).getFullYear();
                while (year >= 2009) { that.data["year"].push(year); year -= 1; }
            }
            deferred.resolve(that.data['year']);
            return deferred.promise;
        },

		getPeriods : function() { 
			var that = this;
            var deferred = $q.defer();
            if (!that.data['period'] || that.data['period'].length == 0)
            {
                that.data["period"] = [ 'FY', 'Q3', 'Q2', 'Q1' ];
            }
            deferred.resolve(that.data['period']);
            return deferred.promise;
		},

        getDomainMembers: function(domain) {
            var that = this;
            var deferred = $q.defer();
            if (that.data[domain] && that.data[domain].length > 0)
            {
                deferred.resolve(that.data[domain]);
                return deferred.promise;
            }

            var url;
            switch (domain)
            {
                case 'sector' :
                    url = API_URL + '/_queries/public/FilerSectorList.jq';
                    break;
            
                case 'generator' :
                    url = API_URL + '/_queries/public/GeneratorList.jq';
                    break;
            
                case 'entityType' :
                    url = API_URL + '/_queries/public/EntityTypeList.jq';
                    break;
            
                case 'stockIndex' :
                    url = API_URL + '/_queries/public/StockIndexList.jq';
                    break;    
            }
            if (url) 
                $http({ method: 'GET', url: url, params: { _method: 'POST' }, cache: true })
                    .success(function(data, status, headers, config) {
                        that.data[domain] =  [];
                        if (data && data.members){
                            data.members.forEach(function(item) {
                                that.data[domain].push(item[domain]);
                            });
                        }
                        deferred.resolve(that.data[domain]);
                    });
            return deferred.promise;
        },

        getTags : function() {
            var that = this;
            var deferred = $q.defer();
            if (!that.data['tag'] || that.data['tag'].length == 0)
            {
                that.data["tag"] = [ "DOW30",
                                "SP500",
                                "FORTUNE100",
                                "PJI" ];
            }
            deferred.resolve(that.data['tag']);
            return deferred.promise;
        },

        getEntities: function() {
            var that = this;
            var deferred = $q.defer();
            if (that.data['entities'] && that.data['entities'].length > 0)
            {
                deferred.resolve(that.data['entities']);
                return deferred.promise;
            }

            $http({ method: 'GET', url: API_URL + '/_queries/public/EntityNameTickerCIKTuples.jq', params: { _method: 'POST' }, cache: true })
                .success(function(data, status, headers, config) {
                    that.data['entities'] =  [];
                    if (data) that.data['entities'] = data.entityNameTickerSymbolCikTuples;
                    deferred.resolve(that.data['entities']);
                });

            return deferred.promise;

        },

        getConceptMaps: function() {
            var that = this;
            var deferred = $q.defer();
            if (that.data['conceptMaps'] && that.data['conceptMaps'].length > 0)
            {
                deferred.resolve(that.data['conceptMaps']);
                return deferred.promise;
            }

            $http({ method: 'GET', url: API_URL + '/_queries/public/ConceptMaps.jq', params: { _method: 'POST' }, cache: true })
                .success(function(data, status, headers, config) {
                    that.data['conceptMaps'] =  [];
                    if (data) that.data['conceptMaps'] = data.availableMaps;
                    deferred.resolve(that.data['conceptMaps']);
                });

            return deferred.promise;
        }
    };
})
// Intercept http calls.
.factory('RootScopeSpinnerInterceptor', function ($q, $rootScope, ngProgressLite) {
        return {
                // On request success
                request: function (config) {
                        ngProgressLite.start();
                        // Return the config or wrap it in a promise if blank.
                        return config || $q.when(config);
                },

                // On request failure
                requestError: function (rejection) {
                        ngProgressLite.start();
                        // Return the promise rejection.
                        return $q.reject(rejection);
                },

                // On response success
                response: function (response) {
                        ngProgressLite.done();
                        // Return the response or promise.
                        return response || $q.when(response);
                },

                // On response failture
                responseError: function (rejection) {
                        ngProgressLite.done();
                        // Return the promise rejection.
                        return $q.reject(rejection);
                }
        };
})
.config(function ($routeProvider, $locationProvider, $httpProvider) {

    $locationProvider.html5Mode(true);
    $httpProvider.interceptors.push('RootScopeSpinnerInterceptor');

    $routeProvider
        .when('/', {
            templateUrl: '/views/home.html'
        })
        .when('/clear', {
            templateUrl: '/views/home.html',
            resolve: {
                cache: ['$angularCacheFactory', function($angularCacheFactory) { $angularCacheFactory.get('secxbrl').removeAll(); }]
            }
        })
        .when('/about', {
            templateUrl: '/views/about.html',
        })
        .when('/api', {
            templateUrl: '/views/api.html',
            controller: 'ApiCtrl'
        })
        .when('/analytics', {
            templateUrl: '/views/analytics.html',
            controller: 'AnalyticsCtrl',
            resolve: {
                years: ['$backend', function($backend) { return $backend.getYears(); }],
{'fraction_non_alphanumeric': 0.14015066756172148, 'fraction_numerical': 0.003431043484746774, 'mean_word_length': 1.3989980318482733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5729041', 'n_tokens_mistral': 3695, 'n_tokens_neox': 3461, 'n_words': 644}