<commit_before>angular.module('n52.core.interface', ['ngResource', 'n52.core.status'])
        .service('interfaceService', ['$http', '$q', 'statusService', 'settingsService', 'utils',
            function ($http, $q, statusService, settingsService, utils) {

                var _createRequestConfigs = function (params) {
                    if (angular.isUndefined(params)) {
                        params = settingsService.additionalParameters;
                    } else {
                        angular.extend(params, settingsService.additionalParameters);
                    }
                    return {
                        params: params,
                        cache: true
                    };
                };

                _errorCallback = function (error, reject) {
                    if (error.data && error.data.userMessage)
                        console.error(error.data.userMessage);
                    reject(error);
                };

                _createIdString = function (id) {
                    return (id === null ? "" : id);
                };

                _pimpTs = function(ts, url) {
                    ts.apiUrl = url;
                    ts.internalId = utils.createInternalId(ts.id, url);
                    return ts;
                };

                this.getServices = function (apiUrl) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'services', _createRequestConfigs({expanded: true})).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getStations = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'stations/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getPhenomena = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'phenomena/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getCategories = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'categories/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getFeatures = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'features/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getProcedures = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'procedures/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getTimeseries = function (id, apiUrl, params) {
                    if (angular.isUndefined(params))
                        params = {};
                    params.expanded = true;
                    params.force_latest_values = true;
                    params.status_intervals = true;
                    params.rendering_hints = true;
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'timeseries/' + _createIdString(id), _createRequestConfigs(params)).then(function (response) {
                            if (angular.isArray(response.data)) {
                                var array = [];
                                angular.forEach(response.data, function (ts) {
                                    array.push(_pimpTs(ts, apiUrl));
                                });
                                resolve(array);
                            } else {
                                resolve(_pimpTs(response.data, apiUrl));
                            }
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getTsData = function (id, apiUrl, timespan, extendedData) {
                    var params = {
                        timespan: timespan,
                        generalize: statusService.status.generalizeData || false,
                        expanded: true,
                        format: 'flot'
                    };
                    if (extendedData) {
                        angular.extend(params, extendedData);
                    }
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'timeseries/' + _createIdString(id) + "/getData", _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };
            }]);<commit_msg>log errors while requesting the API to $log<commit_after>angular.module('n52.core.interface', ['ngResource', 'n52.core.status'])
        .service('interfaceService', ['$http', '$q', 'statusService', 'settingsService', 'utils', '$log',
            function ($http, $q, statusService, settingsService, utils, $log) {

                var _createRequestConfigs = function (params) {
                    if (angular.isUndefined(params)) {
                        params = settingsService.additionalParameters;
                    } else {
                        angular.extend(params, settingsService.additionalParameters);
                    }
                    return {
                        params: params,
                        cache: true
                    };
                };

                _errorCallback = function (error, reject) {
                    if (error.data && error.data.userMessage)
                        $log.error(error.data.userMessage);
                    reject(error);
                };

                _createIdString = function (id) {
                    return (id === null ? "" : id);
                };

                _pimpTs = function(ts, url) {
                    ts.apiUrl = url;
                    ts.internalId = utils.createInternalId(ts.id, url);
                    return ts;
                };

                this.getServices = function (apiUrl) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'services', _createRequestConfigs({expanded: true})).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getStations = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'stations/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getPhenomena = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'phenomena/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getCategories = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'categories/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getFeatures = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'features/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getProcedures = function (id, apiUrl, params) {
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'procedures/' + _createIdString(id), _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getTimeseries = function (id, apiUrl, params) {
                    if (angular.isUndefined(params))
                        params = {};
                    params.expanded = true;
                    params.force_latest_values = true;
                    params.status_intervals = true;
                    params.rendering_hints = true;
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'timeseries/' + _createIdString(id), _createRequestConfigs(params)).then(function (response) {
                            if (angular.isArray(response.data)) {
                                var array = [];
                                angular.forEach(response.data, function (ts) {
                                    array.push(_pimpTs(ts, apiUrl));
                                });
                                resolve(array);
                            } else {
                                resolve(_pimpTs(response.data, apiUrl));
                            }
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };

                this.getTsData = function (id, apiUrl, timespan, extendedData) {
                    var params = {
                        timespan: timespan,
                        generalize: statusService.status.generalizeData || false,
                        expanded: true,
                        format: 'flot'
                    };
                    if (extendedData) {
                        angular.extend(params, extendedData);
                    }
                    return $q(function (resolve, reject) {
                        $http.get(apiUrl + 'timeseries/' + _createIdString(id) + "/getData", _createRequestConfigs(params)).then(function(response) {
                            resolve(response.data);
                        }, function (error) {
                            _errorCallback(error, reject);
                        });
                    });
                };
            }]);
{'fraction_non_alphanumeric': 0.1027723545490043, 'fraction_numerical': 0.0006247559547051933, 'mean_word_length': 1.0385227634511303, 'pattern_counts': {'":': 0, '<': 3, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '216049', 'n_tokens_mistral': 2931, 'n_tokens_neox': 2697, 'n_words': 489}