<commit_before>try{ m = angular.module('proso_apps.services'); } catch (err) { m = angular.module('proso_apps.services', []); }
m.service("configService", ["$http", function($http){
    var self = this;
    var config = null;

    self.get_config = function(app_name, key, default_value){
        if (config === null){
            console.error("Config not loaded");
            return;
        }

        var variable = config[app_name];
        var path =  key.split(".");
        for (var i=0; i < path.length; i++){
            if (typeof variable === 'undefined'){ return default_value;}
            variable = variable[path[i]];
        }
        if (typeof variable === 'undefined'){ return default_value;}
        return variable;
    };

    self.load_config = function(){
        return $http.get("/common/config/")
            .success(function(response){
                self.process_config(response.data);
            })
            .error(function(){
                console.error("Problem while loading config from server");
            });
    };

    self.process_config = function(data){
        config = angular.copy(data);
    };
}]);<commit_msg>proso_common configService: debug mode and faking values with GET parameters<commit_after>try{ m = angular.module('proso_apps.services'); } catch (err) { m = angular.module('proso_apps.services', []); }
m.service("configService", ["$http", function($http){
    var self = this;
    var config = null;
    var GET;

    self.get_config = function(app_name, key, default_value){
        if (GET[app_name + "." + key]) {
            variable = GET[app_name + "." + key];
            if (GET.debug) { console.log(app_name + "." + key, "fake from url", variable); }
            return variable;
        }

        if (config === null){
            console.error("Config not loaded");
            return;
        }

        var variable = config[app_name];
        var path =  key.split(".");
        for (var i=0; i < path.length; i++){
            if (typeof variable === 'undefined'){
                if (GET.debug) { console.log(app_name + "." + key, "use default", default_value); }
                return default_value;
            }
            variable = variable[path[i]];
        }
        if (typeof variable === 'undefined'){
            if (GET.debug) { console.log(app_name + "." + key, "use default", default_value); }
            return default_value;}
        if (GET.debug) { console.log(app_name + "." + key, "from config", variable); }
        return variable;
    };

    self.load_config = function(){
        return $http.get("/common/config/")
            .success(function(response){
                self.process_config(response.data);
            })
            .error(function(){
                console.error("Problem while loading config from server");
            });
    };

    self.process_config = function(data){
        config = angular.copy(data);
    };

    var parse_GET = function(){
        GET = getUrlVars();
    };

    parse_GET();
}]);

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
{'fraction_non_alphanumeric': 0.15767511177347243, 'fraction_numerical': 0.0020864381520119225, 'mean_word_length': 2.1189591078066914, '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': '2398561', 'n_tokens_mistral': 975, 'n_tokens_neox': 947, 'n_words': 220}