<commit_before>/**
 * @ngdoc service
 * @name Server
 * @description
 * Handles the http requests to and from the server
 */
angular.module('locApp.modules.profile.services')
    .factory('Server', function($q, $http, localStorageService) {

        var server = {};

        /**
         * @ngdoc function
         * @name get
         * @description
         * Returns a promise with the server's response to the get request sent to
         * url with params
         * @param {type} url - where to send the request (relative path)
         * @param {type} params - params to pass in the request
         * @returns {promise} the server's response
         */
        server.get = function(url, params, useLocalStorage) {
            var deferred = $q.defer();
            serverPath = url.match(/\/verso\//) ? '//' + serverHostname + ':3001' : serverPath;
            
            if(useLocalStorage && sessionStorage.getItem(url)) {
                deferred.resolve(JSON.parse(sessionStorage.getItem(url)));
                return deferred.promise;
            }
            
            // HTTP request to get the data
            $http({
                //Include a random number to prevent early version of IE from
                //caching the request
                url: serverPath + url + '?' + Math.random(),
                method: "GET",
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                params: params,
                cache: false
            })
            .then(function(response) { // Success
                if(useLocalStorage) {
                    sessionStorage.setItem(url, JSON.stringify(response.data));
                }<commit_msg>Update GET service to use verso.<commit_after>/**
 * @ngdoc service
 * @name Server
 * @description
 * Handles the http requests to and from the server
 */
angular.module('locApp.modules.profile.services')
    .factory('Server', function($q, $http, localStorageService, $sce) {

        var server = {};

        /**
         * @ngdoc function
         * @name get
         * @description
         * Returns a promise with the server's response to the get request sent to
         * url with params
         * @param {type} url - where to send the request (relative path)
         * @param {type} params - params to pass in the request
         * @returns {promise} the server's response
         */
        server.get = function(url, params, useLocalStorage) {
            var deferred = $q.defer();
            serverPath = url.match(/\/verso\//) ? '//' + serverHostname + ':3001' : serverPath;
            
            if(useLocalStorage && sessionStorage.getItem(url)) {
                deferred.resolve(JSON.parse(sessionStorage.getItem(url)));
                return deferred.promise;
            }
            // HTTP request to get the data
            $http({
                //Include a random number to prevent early version of IE from
                //caching the request
                url: serverPath + url,
                method: "GET",
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                params: params,
                cache: false
            })
            .then(function(response) { // Success
                if(useLocalStorage) {
                    sessionStorage.setItem(url, JSON.stringify(response.data));
                }
{'fraction_non_alphanumeric': 0.1096413874191652, 'fraction_numerical': 0.0023515579071134627, 'mean_word_length': 1.6669278996865204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1691152', 'n_tokens_mistral': 874, 'n_tokens_neox': 836, 'n_words': 251}